http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/integration-test/ThinClientHelper.hpp ---------------------------------------------------------------------- diff --git a/src/cppcache/integration-test/ThinClientHelper.hpp b/src/cppcache/integration-test/ThinClientHelper.hpp index 49c9fc8..ec9ba2b 100644 --- a/src/cppcache/integration-test/ThinClientHelper.hpp +++ b/src/cppcache/integration-test/ThinClientHelper.hpp @@ -48,13 +48,13 @@ using namespace unitTests; CacheHelper* cacheHelper = NULL; void initGridClient(const bool isthinClient, - const PropertiesPtr& configPtr = NULLPTR) { + const PropertiesPtr& configPtr = nullptr) { static bool s_isGridClient = true; s_isGridClient = !s_isGridClient; if (cacheHelper == NULL) { PropertiesPtr config = configPtr; - if (config == NULLPTR) { + if (config == nullptr) { config = Properties::create(); } config->insert("grid-client", s_isGridClient ? "true" : "false"); @@ -64,7 +64,7 @@ void initGridClient(const bool isthinClient, } void initClient(const bool isthinClient, - const PropertiesPtr& configPtr = NULLPTR) { + const PropertiesPtr& configPtr = nullptr) { if (cacheHelper == NULL) { cacheHelper = new CacheHelper(isthinClient, configPtr); } @@ -73,7 +73,7 @@ void initClient(const bool isthinClient, void initClientWithPool(const bool isthinClient, const char* poolName, const char* locators, const char* serverGroup, - const PropertiesPtr& configPtr = NULLPTR, + const PropertiesPtr& configPtr = nullptr, int redundancy = 0, bool clientNotification = false, int subscriptionAckInterval = -1, int connections = -1, int loadConditioningInterval = -1, @@ -88,10 +88,10 @@ void initClientWithPool(const bool isthinClient, const char* poolName, } /* For HA Clients */ -void initClient(int redundancyLevel, const PropertiesPtr& configPtr = NULLPTR) { +void initClient(int redundancyLevel, const PropertiesPtr& configPtr = nullptr) { if (cacheHelper == NULL) { PropertiesPtr config = configPtr; - if (config == NULLPTR) { + if (config == nullptr) { config = Properties::create(); } cacheHelper = new CacheHelper(redundancyLevel, config); @@ -100,13 +100,13 @@ void initClient(int redundancyLevel, const PropertiesPtr& configPtr = NULLPTR) { } void initGridClient(int redundancyLevel, - const PropertiesPtr& configPtr = NULLPTR) { + const PropertiesPtr& configPtr = nullptr) { static bool s_isGridClient = true; s_isGridClient = !s_isGridClient; if (cacheHelper == NULL) { PropertiesPtr config = configPtr; - if (config == NULLPTR) { + if (config == nullptr) { config = Properties::create(); } config->insert("grid-client", s_isGridClient ? "true" : "false"); @@ -178,7 +178,7 @@ void _verifyEntry(const char* name, const char* key, const char* val, free(buf); RegionPtr regPtr = getHelper()->getRegion(name); - ASSERT(regPtr != NULLPTR, "Region not found."); + ASSERT(regPtr != nullptr, "Region not found."); CacheableKeyPtr keyPtr = createKey(key); @@ -215,10 +215,10 @@ void _verifyEntry(const char* name, const char* key, const char* val, } if (val != NULL) { - CacheableStringPtr checkPtr = - dynCast<CacheableStringPtr>(regPtr->get(keyPtr)); + auto checkPtr = + std::dynamic_pointer_cast<CacheableString>(regPtr->get(keyPtr)); - ASSERT(checkPtr != NULLPTR, "Value Ptr should not be null."); + ASSERT(checkPtr != nullptr, "Value Ptr should not be null."); char buf[1024]; sprintf(buf, "In verify loop, get returned %s for key %s", checkPtr->asChar(), key); @@ -285,7 +285,7 @@ void _verifyIntEntry(const char* name, const char* key, const int val, } RegionPtr regPtr = getHelper()->getRegion(name); - ASSERT(regPtr != NULLPTR, "Region not found."); + ASSERT(regPtr != nullptr, "Region not found."); CacheableKeyPtr keyPtr = createKey(key); @@ -335,10 +335,10 @@ void _verifyIntEntry(const char* name, const char* key, const int val, } if (val != 0) { - CacheableInt32Ptr checkPtr = - dynCast<CacheableInt32Ptr>(regPtr->get(keyPtr)); + auto checkPtr = + std::dynamic_pointer_cast<CacheableInt32>(regPtr->get(keyPtr)); - ASSERT(checkPtr != NULLPTR, "Value Ptr should not be null."); + ASSERT(checkPtr != nullptr, "Value Ptr should not be null."); char buf[1024]; sprintf(buf, "In verify loop, get returned %d for key %s", checkPtr->value(), key); @@ -368,7 +368,7 @@ void _verifyIntEntry(const char* name, const char* key, const int val, void createRegion(const char* name, bool ackMode, bool clientNotificationEnabled = false, - const CacheListenerPtr& listener = NULLPTR, + const CacheListenerPtr& listener = nullptr, bool caching = true) { LOG("createRegion() entered."); fprintf(stdout, "Creating region -- %s ackMode is %d\n", name, ackMode); @@ -376,7 +376,7 @@ void createRegion(const char* name, bool ackMode, // ack, caching RegionPtr regPtr = getHelper()->createRegion(name, ackMode, caching, listener, clientNotificationEnabled); - ASSERT(regPtr != NULLPTR, "Failed to create region."); + ASSERT(regPtr != nullptr, "Failed to create region."); LOG("Region created."); } RegionPtr createOverflowRegion(const char* name, bool ackMode, int lel = 0, @@ -400,7 +400,7 @@ RegionPtr createOverflowRegion(const char* name, bool ackMode, int lel = 0, RegionAttributesPtr rattrsPtr = af.createRegionAttributes(); CachePtr cache = getHelper()->cachePtr; - CacheImpl* cacheImpl = CacheRegionHelper::getCacheImpl(cache.ptr()); + CacheImpl* cacheImpl = CacheRegionHelper::getCacheImpl(cache.get()); RegionPtr regionPtr; cacheImpl->createRegion(name, rattrsPtr, regionPtr); return regionPtr; @@ -409,7 +409,7 @@ RegionPtr createOverflowRegion(const char* name, bool ackMode, int lel = 0, RegionPtr createPooledRegion(const char* name, bool ackMode, const char* locators, const char* poolname, bool clientNotificationEnabled = false, - const CacheListenerPtr& listener = NULLPTR, + const CacheListenerPtr& listener = nullptr, bool caching = true) { LOG("createPooledRegion() entered."); fprintf(stdout, "Creating region -- %s ackMode is %d\n", name, ackMode); @@ -424,7 +424,7 @@ RegionPtr createPooledRegion(const char* name, bool ackMode, name, ackMode, locators, poolname, caching, clientNotificationEnabled, 0, 0, 0, 0, 0, listener); - ASSERT(regPtr != NULLPTR, "Failed to create region."); + ASSERT(regPtr != nullptr, "Failed to create region."); LOG("Region created."); return regPtr; } @@ -432,7 +432,7 @@ RegionPtr createPooledRegion(const char* name, bool ackMode, PoolPtr findPool(const char* poolName) { LOG("findPool() entered."); PoolPtr poolPtr = PoolManager::find(poolName); - ASSERT(poolPtr != NULLPTR, "Failed to find pool."); + ASSERT(poolPtr != nullptr, "Failed to find pool."); return poolPtr; } PoolPtr createPool(const char* poolName, const char* locators, @@ -445,7 +445,7 @@ PoolPtr createPool(const char* poolName, const char* locators, PoolPtr poolPtr = getHelper()->createPool( poolName, locators, serverGroup, redundancy, clientNotification, subscriptionAckInterval, connections, loadConditioningInterval); - ASSERT(poolPtr != NULLPTR, "Failed to create pool."); + ASSERT(poolPtr != nullptr, "Failed to create pool."); LOG("Pool created."); return poolPtr; } @@ -460,7 +460,7 @@ PoolPtr createPoolAndDestroy(const char* poolName, const char* locators, PoolPtr poolPtr = getHelper()->createPool( poolName, locators, serverGroup, redundancy, clientNotification, subscriptionAckInterval, connections); - ASSERT(poolPtr != NULLPTR, "Failed to create pool."); + ASSERT(poolPtr != nullptr, "Failed to create pool."); poolPtr->destroy(); LOG("Pool created and destroyed."); return poolPtr; @@ -473,7 +473,7 @@ PoolPtr createPool2(const char* poolName, const char* locators, PoolPtr poolPtr = getHelper()->createPool2( poolName, locators, serverGroup, servers, redundancy, clientNotification); - ASSERT(poolPtr != NULLPTR, "Failed to create pool."); + ASSERT(poolPtr != nullptr, "Failed to create pool."); LOG("Pool created."); return poolPtr; } @@ -485,7 +485,7 @@ RegionPtr createRegionAndAttachPool( LOG("createRegionAndAttachPool() entered."); RegionPtr regPtr = getHelper()->createRegionAndAttachPool( name, ack, poolName, caching, ettl, eit, rttl, rit, lel, action); - ASSERT(regPtr != NULLPTR, "Failed to create region."); + ASSERT(regPtr != nullptr, "Failed to create region."); LOG("Region created."); return regPtr; } @@ -500,7 +500,7 @@ void createEntry(const char* name, const char* key, const char* value) { CacheableStringPtr valPtr = CacheableString::create(value); RegionPtr regPtr = getHelper()->getRegion(name); - ASSERT(regPtr != NULLPTR, "Region not found."); + ASSERT(regPtr != nullptr, "Region not found."); ASSERT(!regPtr->containsKey(keyPtr), "Key should not have been found in region."); @@ -526,7 +526,7 @@ void updateEntry(const char* name, const char* key, const char* value, CacheableStringPtr valPtr = CacheableString::create(value); RegionPtr regPtr = getHelper()->getRegion(name); - ASSERT(regPtr != NULLPTR, "Region not found."); + ASSERT(regPtr != nullptr, "Region not found."); if (checkKey) { ASSERT(regPtr->containsKey(keyPtr), @@ -558,7 +558,7 @@ void doNetsearch(const char* name, const char* key, const char* value, RegionPtr regPtr = getHelper()->getRegion(name); fprintf(stdout, "netsearch region %s\n", regPtr->getName()); fflush(stdout); - ASSERT(regPtr != NULLPTR, "Region not found."); + ASSERT(regPtr != nullptr, "Region not found."); // ASSERT( !regPtr->containsKey( keyPtr ), "Key should not have been found in // region." ); @@ -567,10 +567,10 @@ void doNetsearch(const char* name, const char* key, const char* value, "Value should not have been found in region."); } - CacheableStringPtr checkPtr = - dynCast<CacheableStringPtr>(regPtr->get(keyPtr)); // force a netsearch + auto checkPtr = std::dynamic_pointer_cast<CacheableString>( + regPtr->get(keyPtr)); // force a netsearch - if (checkPtr != NULLPTR) { + if (checkPtr != nullptr) { LOG("checkPtr is not null"); char buf[1024]; sprintf(buf, "In net search, get returned %s for key %s", @@ -595,7 +595,7 @@ void createIntEntry(const char* name, const char* key, const int value, CacheableInt32Ptr valPtr = CacheableInt32::create(value); RegionPtr regPtr = getHelper()->getRegion(name); - ASSERT(regPtr != NULLPTR, "Region not found."); + ASSERT(regPtr != nullptr, "Region not found."); if (onlyCreate) { ASSERT(!regPtr->containsKey(keyPtr), @@ -619,7 +619,7 @@ void invalidateEntry(const char* name, const char* key) { CacheableKeyPtr keyPtr = CacheableKey::create(key); RegionPtr regPtr = getHelper()->getRegion(name); - ASSERT(regPtr != NULLPTR, "Region not found."); + ASSERT(regPtr != nullptr, "Region not found."); ASSERT(regPtr->containsKey(keyPtr), "Key should have been found in region."); ASSERT(regPtr->containsValueForKey(keyPtr), @@ -640,7 +640,7 @@ void destroyEntry(const char* name, const char* key) { CacheableKeyPtr keyPtr = CacheableKey::create(key); RegionPtr regPtr = getHelper()->getRegion(name); - ASSERT(regPtr != NULLPTR, "Region not found."); + ASSERT(regPtr != nullptr, "Region not found."); ASSERT(regPtr->containsKey(keyPtr), "Key should have been found in region."); @@ -663,7 +663,7 @@ class RegionOperations { RegionOperations(const char* name) : m_regionPtr(getHelper()->getRegion(name)) {} - void putOp(int keys = 1, const UserDataPtr& aCallbackArgument = NULLPTR) { + void putOp(int keys = 1, const UserDataPtr& aCallbackArgument = nullptr) { char keybuf[100]; char valbuf[100]; for (int i = 1; i <= keys; i++) { @@ -674,7 +674,7 @@ class RegionOperations { } } void invalidateOp(int keys = 1, - const UserDataPtr& aCallbackArgument = NULLPTR) { + const UserDataPtr& aCallbackArgument = nullptr) { char keybuf[100]; char valbuf[100]; for (int i = 1; i <= keys; i++) { @@ -683,7 +683,7 @@ class RegionOperations { m_regionPtr->localInvalidate(keybuf, aCallbackArgument); } } - void destroyOp(int keys = 1, const UserDataPtr& aCallbackArgument = NULLPTR) { + void destroyOp(int keys = 1, const UserDataPtr& aCallbackArgument = nullptr) { char keybuf[100]; char valbuf[100]; for (int i = 1; i <= keys; i++) { @@ -692,7 +692,7 @@ class RegionOperations { m_regionPtr->destroy(keybuf, aCallbackArgument); } } - void removeOp(int keys = 1, const UserDataPtr& aCallbackArgument = NULLPTR) { + void removeOp(int keys = 1, const UserDataPtr& aCallbackArgument = nullptr) { char keybuf[100]; char valbuf[100]; for (int i = 1; i <= keys; i++) {
http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/integration-test/ThinClientInterest1.hpp ---------------------------------------------------------------------- diff --git a/src/cppcache/integration-test/ThinClientInterest1.hpp b/src/cppcache/integration-test/ThinClientInterest1.hpp index 5d01278..0185704 100644 --- a/src/cppcache/integration-test/ThinClientInterest1.hpp +++ b/src/cppcache/integration-test/ThinClientInterest1.hpp @@ -69,7 +69,7 @@ DUNIT_TASK_DEFINITION(CLIENT2, setupClient2_Pool_Locator) createPooledRegion(regionNames[0], false /*ack mode*/, locatorsG, "__TEST_POOL1__", true /*client notification*/); RegionPtr regPtr = getHelper()->getRegion(regionNames[0]); - regPtr->registerAllKeys(false, NULLPTR, true); + regPtr->registerAllKeys(false, nullptr, true); SLEEP(200); } END_TASK_DEFINITION http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/integration-test/ThinClientInterest3.hpp ---------------------------------------------------------------------- diff --git a/src/cppcache/integration-test/ThinClientInterest3.hpp b/src/cppcache/integration-test/ThinClientInterest3.hpp index cd42325..3eb0c0f 100644 --- a/src/cppcache/integration-test/ThinClientInterest3.hpp +++ b/src/cppcache/integration-test/ThinClientInterest3.hpp @@ -96,8 +96,8 @@ DUNIT_TASK_DEFINITION(CLIENT1, SetupClient1_Pool_Locator) initClient(true); createPooledRegion(regionNames[0], false /*ack mode*/, locatorsG, "__TEST_POOL1__", true /*client notification*/); - reg1Listener1 = new TallyListener(); - reg1Writer1 = new TallyWriter(); + reg1Listener1 = std::make_shared<TallyListener>(); + reg1Writer1 = std::make_shared<TallyWriter>(); setCacheListener(regionNames[0], reg1Listener1); setCacheWriter(regionNames[0], reg1Writer1); } @@ -111,7 +111,7 @@ DUNIT_TASK_DEFINITION(CLIENT1, testCreatesAndUpdates) VectorOfCacheableKey keys; keys.push_back(keyPtr1); keys.push_back(keyPtr2); - regPtr->registerKeys(keys, NULLPTR); + regPtr->registerKeys(keys); // Do a create followed by a create on the same key /*NIL: Changed the asserion due to the change in invalidate. http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/integration-test/ThinClientInterest3Cacheless.hpp ---------------------------------------------------------------------- diff --git a/src/cppcache/integration-test/ThinClientInterest3Cacheless.hpp b/src/cppcache/integration-test/ThinClientInterest3Cacheless.hpp index 0461fc8..3943e3a 100644 --- a/src/cppcache/integration-test/ThinClientInterest3Cacheless.hpp +++ b/src/cppcache/integration-test/ThinClientInterest3Cacheless.hpp @@ -96,9 +96,9 @@ DUNIT_TASK_DEFINITION(CLIENT1, SetupClient1_Pool_Locator) initClient(true); createPooledRegion(regionNames[0], false /*ack mode*/, locatorsG, "__TEST_POOL1__", true /*client notification*/, - NULLPTR /*cachelistener*/, false /*caching*/); - reg1Listener1 = new TallyListener(); - reg1Writer1 = new TallyWriter(); + nullptr /*cachelistener*/, false /*caching*/); + reg1Listener1 = std::make_shared<TallyListener>(); + reg1Writer1 = std::make_shared<TallyWriter>(); setCacheListener(regionNames[0], reg1Listener1); setCacheWriter(regionNames[0], reg1Writer1); } @@ -112,7 +112,7 @@ DUNIT_TASK_DEFINITION(CLIENT1, testCreatesAndUpdates) VectorOfCacheableKey keys; keys.push_back(keyPtr1); keys.push_back(keyPtr2); - regPtr->registerKeys(keys, NULLPTR); + regPtr->registerKeys(keys); regPtr->create(keyPtr1, vals[1]); numCreates++; http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/integration-test/ThinClientInterestList.hpp ---------------------------------------------------------------------- diff --git a/src/cppcache/integration-test/ThinClientInterestList.hpp b/src/cppcache/integration-test/ThinClientInterestList.hpp index 468e43a..1f09290 100644 --- a/src/cppcache/integration-test/ThinClientInterestList.hpp +++ b/src/cppcache/integration-test/ThinClientInterestList.hpp @@ -85,7 +85,7 @@ void _verifyEntry(const char* name, const char* key, const char* val, free(buf); RegionPtr regPtr = getHelper()->getRegion(name); - ASSERT(regPtr != NULLPTR, "Region not found."); + ASSERT(regPtr != nullptr, "Region not found."); CacheableKeyPtr keyPtr = createKey(key); @@ -134,10 +134,9 @@ void _verifyEntry(const char* name, const char* key, const char* val, } if (val != NULL) { - CacheableStringPtr checkPtr = - dynCast<CacheableStringPtr>(regPtr->get(keyPtr)); + auto checkPtr = std::dynamic_pointer_cast<CacheableString>(regPtr->get(keyPtr)); - ASSERT(checkPtr != NULLPTR, "Value Ptr should not be null."); + ASSERT(checkPtr != nullptr, "Value Ptr should not be null."); char buf[1024]; sprintf(buf, "In verify loop, get returned %s for key %s", checkPtr->asChar(), key); @@ -205,7 +204,7 @@ void createPooledRegion(const char* name, bool ackMode, const char* locatorsG, RegionPtr regPtr = getHelper()->createPooledRegion(name, ackMode, locatorsG, poolname, cachingEnable, clientNotificationEnabled); - ASSERT(regPtr != NULLPTR, "Failed to create region."); + ASSERT(regPtr != nullptr, "Failed to create region."); LOG("Pooled Region created."); } void createEntry(const char* name, const char* key, const char* value = NULL) { @@ -221,7 +220,7 @@ void createEntry(const char* name, const char* key, const char* value = NULL) { CacheableStringPtr valPtr = CacheableString::create(value); RegionPtr regPtr = getHelper()->getRegion(name); - ASSERT(regPtr != NULLPTR, "Region not found."); + ASSERT(regPtr != nullptr, "Region not found."); ASSERT(!regPtr->containsKey(keyPtr), "Key should not have been found in region."); @@ -246,7 +245,7 @@ void updateEntry(const char* name, const char* key, const char* value) { CacheableStringPtr valPtr = CacheableString::create(value); RegionPtr regPtr = getHelper()->getRegion(name); - ASSERT(regPtr != NULLPTR, "Region not found."); + ASSERT(regPtr != nullptr, "Region not found."); ASSERT(regPtr->containsKey(keyPtr), "Key should have been found in region."); ASSERT(regPtr->containsValueForKey(keyPtr), @@ -272,17 +271,16 @@ void doNetsearch(const char* name, const char* key, const char* value) { RegionPtr regPtr = getHelper()->getRegion(name); fprintf(stdout, "netsearch region %s\n", regPtr->getName()); fflush(stdout); - ASSERT(regPtr != NULLPTR, "Region not found."); + ASSERT(regPtr != nullptr, "Region not found."); ASSERT(!regPtr->containsKey(keyPtr), "Key should not have been found in region."); ASSERT(!regPtr->containsValueForKey(keyPtr), "Value should not have been found in region."); - CacheableStringPtr checkPtr = - dynCast<CacheableStringPtr>(regPtr->get(keyPtr)); // force a netsearch + auto checkPtr = std::dynamic_pointer_cast<CacheableString>(regPtr->get(keyPtr)); // force a netsearch - if (checkPtr != NULLPTR) { + if (checkPtr != nullptr) { LOG("checkPtr is not null"); char buf[1024]; sprintf(buf, "In net search, get returned %s for key %s", @@ -339,8 +337,8 @@ DUNIT_TASK_DEFINITION(CLIENT1, StepThree) VectorOfCacheableKey keys0, keys1; keys0.push_back(keyPtr1); keys1.push_back(keyPtr3); - regPtr0->registerKeys(keys0, NULLPTR); - regPtr1->registerKeys(keys1, NULLPTR); + regPtr0->registerKeys(keys0); + regPtr1->registerKeys(keys1); // createEntry( regionNames[0], keys[1] ); // createEntry( regionNames[1], keys[3] ); @@ -359,7 +357,7 @@ DUNIT_TASK_DEFINITION(CLIENT2, StepFour) RegionPtr regPtr0 = getHelper()->getRegion(regionNames[0]); VectorOfCacheableKey keys0; keys0.push_back(keyPtr0); - regPtr0->registerKeys(keys0, NULLPTR); + regPtr0->registerKeys(keys0); LOG("StepFour complete."); } END_TASK_DEFINITION http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/integration-test/ThinClientInterestList2.hpp ---------------------------------------------------------------------- diff --git a/src/cppcache/integration-test/ThinClientInterestList2.hpp b/src/cppcache/integration-test/ThinClientInterestList2.hpp index 1cdd14c..23e8d08 100644 --- a/src/cppcache/integration-test/ThinClientInterestList2.hpp +++ b/src/cppcache/integration-test/ThinClientInterestList2.hpp @@ -85,7 +85,7 @@ void _verifyEntry(const char* name, const char* key, const char* val, free(buf); RegionPtr regPtr = getHelper()->getRegion(name); - ASSERT(regPtr != NULLPTR, "Region not found."); + ASSERT(regPtr != nullptr, "Region not found."); CacheableKeyPtr keyPtr = createKey(key); @@ -134,10 +134,9 @@ void _verifyEntry(const char* name, const char* key, const char* val, } if (val != NULL) { - CacheableStringPtr checkPtr = - dynCast<CacheableStringPtr>(regPtr->get(keyPtr)); + auto checkPtr = std::dynamic_pointer_cast<CacheableString>(regPtr->get(keyPtr)); - ASSERT(checkPtr != NULLPTR, "Value Ptr should not be null."); + ASSERT(checkPtr != nullptr, "Value Ptr should not be null."); char buf[1024]; sprintf(buf, "In verify loop, get returned %s for key %s", checkPtr->asChar(), key); @@ -205,7 +204,7 @@ void createPooledRegion(const char* name, bool ackMode, const char* locators, RegionPtr regPtr = getHelper()->createPooledRegion(name, ackMode, locatorsG, poolname, cachingEnable, clientNotificationEnabled); - ASSERT(regPtr != NULLPTR, "Failed to create region."); + ASSERT(regPtr != nullptr, "Failed to create region."); LOG("Pooled Region created."); } void createEntry(const char* name, const char* key, const char* value = NULL) { @@ -221,7 +220,7 @@ void createEntry(const char* name, const char* key, const char* value = NULL) { CacheableStringPtr valPtr = CacheableString::create(value); RegionPtr regPtr = getHelper()->getRegion(name); - ASSERT(regPtr != NULLPTR, "Region not found."); + ASSERT(regPtr != nullptr, "Region not found."); ASSERT(!regPtr->containsKey(keyPtr), "Key should not have been found in region."); @@ -246,7 +245,7 @@ void updateEntry(const char* name, const char* key, const char* value) { CacheableStringPtr valPtr = CacheableString::create(value); RegionPtr regPtr = getHelper()->getRegion(name); - ASSERT(regPtr != NULLPTR, "Region not found."); + ASSERT(regPtr != nullptr, "Region not found."); ASSERT(regPtr->containsKey(keyPtr), "Key should have been found in region."); // ASSERT( regPtr->containsValueForKey( keyPtr ), "Value should have been @@ -272,17 +271,16 @@ void doNetsearch(const char* name, const char* key, const char* value) { RegionPtr regPtr = getHelper()->getRegion(name); fprintf(stdout, "netsearch region %s\n", regPtr->getName()); fflush(stdout); - ASSERT(regPtr != NULLPTR, "Region not found."); + ASSERT(regPtr != nullptr, "Region not found."); ASSERT(!regPtr->containsKey(keyPtr), "Key should not have been found in region."); ASSERT(!regPtr->containsValueForKey(keyPtr), "Value should not have been found in region."); - CacheableStringPtr checkPtr = - dynCast<CacheableStringPtr>(regPtr->get(keyPtr)); // force a netsearch + auto checkPtr = std::dynamic_pointer_cast<CacheableString>(regPtr->get(keyPtr)); // force a netsearch - if (checkPtr != NULLPTR) { + if (checkPtr != nullptr) { LOG("checkPtr is not null"); char buf[1024]; sprintf(buf, "In net search, get returned %s for key %s", http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/integration-test/ThinClientListenerInit.hpp ---------------------------------------------------------------------- diff --git a/src/cppcache/integration-test/ThinClientListenerInit.hpp b/src/cppcache/integration-test/ThinClientListenerInit.hpp index 07ea409..340206a 100644 --- a/src/cppcache/integration-test/ThinClientListenerInit.hpp +++ b/src/cppcache/integration-test/ThinClientListenerInit.hpp @@ -56,13 +56,13 @@ class ThinClientTallyLoader : public TallyLoader { CacheablePtr load(const RegionPtr& rp, const CacheableKeyPtr& key, const UserDataPtr& aCallbackArgument) { - int32_t loadValue = dynCast<CacheableInt32Ptr>( + int32_t loadValue = std::dynamic_pointer_cast<CacheableInt32>( TallyLoader::load(rp, key, aCallbackArgument)) ->value(); char lstrvalue[32]; sprintf(lstrvalue, "%i", loadValue); CacheableStringPtr lreturnValue = CacheableString::create(lstrvalue); - if (key != NULLPTR && (NULL != rp->getAttributes()->getEndpoints() || + if (key != nullptr && (NULL != rp->getAttributes()->getEndpoints() || rp->getAttributes()->getPoolName() != NULL)) { LOGDEBUG("Putting the value (%s) for local region clients only ", lstrvalue); @@ -122,11 +122,11 @@ END_TASK_DEFINITION DUNIT_TASK_DEFINITION(CLIENT1, SetupClient_Pooled_Locator) { initClient(true); - reg1Listener1 = new TallyListener(); + reg1Listener1 = std::make_shared<TallyListener>(); createPooledRegion(regionNames[0], false, locatorsG, poolName, true, reg1Listener1); - reg1Loader1 = new ThinClientTallyLoader(); - reg1Writer1 = new TallyWriter(); + reg1Loader1 = std::make_shared<ThinClientTallyLoader>(); + reg1Writer1 = std::make_shared<TallyWriter>(); setCacheLoader(regionNames[0], reg1Loader1); setCacheWriter(regionNames[0], reg1Writer1); } @@ -138,7 +138,7 @@ DUNIT_TASK_DEFINITION(CLIENT1, testLoaderAndWriter) CacheableKeyPtr keyPtr = CacheableKey::create(keys[0]); VectorOfCacheableKey keys; keys.push_back(keyPtr); - regPtr->registerKeys(keys, NULLPTR); + regPtr->registerKeys(keys); /*NIL: Changed the asserion due to the change in invalidate. Now we create new entery for every invalidate event received or @@ -146,7 +146,7 @@ DUNIT_TASK_DEFINITION(CLIENT1, testLoaderAndWriter) so expect containsKey to returns true insted of false earlier. */ ASSERT(regPtr->containsKey(keyPtr), "Key should found in region."); // now having all the Callbacks set, lets call the loader and writer - ASSERT(regPtr->get(keyPtr) != NULLPTR, "Expected non null value"); + ASSERT(regPtr->get(keyPtr) != nullptr, "Expected non null value"); RegionEntryPtr regEntryPtr = regPtr->getEntry(keyPtr); CacheablePtr valuePtr = regEntryPtr->getValue(); @@ -168,7 +168,7 @@ DUNIT_TASK_DEFINITION(CLIENT1, testCreatesAndUpdates) VectorOfCacheableKey keys; keys.push_back(keyPtr1); keys.push_back(keyPtr2); - regPtr->registerKeys(keys, NULLPTR); + regPtr->registerKeys(keys); // Do a create followed by a create on the same key /*NIL: Changed the asserion due to the change in invalidate. http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/integration-test/ThinClientListenerWriter.hpp ---------------------------------------------------------------------- diff --git a/src/cppcache/integration-test/ThinClientListenerWriter.hpp b/src/cppcache/integration-test/ThinClientListenerWriter.hpp index d0fbde4..b150c9f 100644 --- a/src/cppcache/integration-test/ThinClientListenerWriter.hpp +++ b/src/cppcache/integration-test/ThinClientListenerWriter.hpp @@ -96,7 +96,7 @@ void SimpleCacheListener::afterRegionDestroy(const RegionEvent& event) { void SimpleCacheListener::close(const RegionPtr& region) { LOGINFO("SimpleCacheListener: Got an close event for %s region .", - region.ptr()->getName()); + region.get()->getName()); } void SimpleCacheListener::afterRegionClear(const RegionEvent& event) { @@ -193,7 +193,7 @@ DUNIT_TASK_DEFINITION(CLIENT1, SetupClient1_Pooled_Locator) initClient(true); LOG("Creating region in CLIENT1, no-ack, no-cache, no-listener"); createPooledRegion(regionNames[0], false, locatorsG, poolName, true, - NULLPTR, false); + nullptr, false); } END_TASK_DEFINITION @@ -201,11 +201,11 @@ DUNIT_TASK_DEFINITION(CLIENT1, SetupClient1withCachingEnabled_Pooled_Locator) { initClient(true); LOG("Creating region in CLIENT1, no-ack, no-cache, no-listener"); - createPooledRegion(myRegNames[0], false, locatorsG, poolName, true, NULLPTR, + createPooledRegion(myRegNames[0], false, locatorsG, poolName, true, nullptr, true); - createPooledRegion(myRegNames[1], false, locatorsG, poolName, true, NULLPTR, + createPooledRegion(myRegNames[1], false, locatorsG, poolName, true, nullptr, true); - createPooledRegion(myRegNames[2], false, locatorsG, poolName, true, NULLPTR, + createPooledRegion(myRegNames[2], false, locatorsG, poolName, true, nullptr, true); // create subregion @@ -249,14 +249,14 @@ END_TASK_DEFINITION DUNIT_TASK_DEFINITION(CLIENT2, Register2WithFalse) { RegionPtr regPtr0 = getHelper()->getRegion(regionNames[0]); - regPtr0->registerAllKeys(false, NULLPTR, false, false); + regPtr0->registerAllKeys(false, nullptr, false, false); } END_TASK_DEFINITION DUNIT_TASK_DEFINITION(CLIENT3, Register3WithFalse) { RegionPtr regPtr0 = getHelper()->getRegion(regionNames[0]); - regPtr0->registerAllKeys(false, NULLPTR, false, false); + regPtr0->registerAllKeys(false, nullptr, false, false); } END_TASK_DEFINITION @@ -265,10 +265,10 @@ DUNIT_TASK_DEFINITION(CLIENT2, SetupClient2_Pooled_Locator) initClient(true); LOG("Creating region in CLIENT2 , no-ack, no-cache, with-listener and " "writer"); - regListener = new TallyListener(); + regListener = std::make_shared<TallyListener>(); createPooledRegion(regionNames[0], false, locatorsG, poolName, true, regListener, false); - regWriter = new TallyWriter(); + regWriter = std::make_shared<TallyWriter>(); setCacheWriter(regionNames[0], regWriter); RegionPtr regPtr0 = getHelper()->getRegion(regionNames[0]); // regPtr0->registerAllKeys(); @@ -281,8 +281,8 @@ DUNIT_TASK_DEFINITION(CLIENT2, SetupClient2withCachingEnabled_Pooled_Locator) initClient(true); LOG("Creating region in CLIENT2 , no-ack, no-cache, with-listener and " "writer"); - parentRegCacheListener = new SimpleCacheListener(); - distRegCacheListener = new SimpleCacheListener(); + parentRegCacheListener = std::make_shared<SimpleCacheListener>(); + distRegCacheListener = std::make_shared<SimpleCacheListener>(); createPooledRegion(myRegNames[0], false, locatorsG, poolName, true, distRegCacheListener, true); @@ -291,7 +291,7 @@ DUNIT_TASK_DEFINITION(CLIENT2, SetupClient2withCachingEnabled_Pooled_Locator) createPooledRegion(myRegNames[2], false, locatorsG, poolName, true, parentRegCacheListener, true); - regWriter = new TallyWriter(); + regWriter = std::make_shared<TallyWriter>(); setCacheWriter(myRegNames[2], regWriter); // create subregion @@ -311,7 +311,7 @@ DUNIT_TASK_DEFINITION(CLIENT2, SetupClient2withCachingEnabled_Pooled_Locator) AttributesMutatorPtr subregAttrMutatorPtr = subregPtr1->getAttributesMutator(); - subRegCacheListener = new SimpleCacheListener(); + subRegCacheListener = std::make_shared<SimpleCacheListener>(); subregAttrMutatorPtr->setCacheListener(subRegCacheListener); LOG("StepTwo_Pool complete."); @@ -324,10 +324,10 @@ DUNIT_TASK_DEFINITION(CLIENT3, SetupClient3_Pooled_Locator) initClient(true); LOG("Creating region in CLIENT2 , no-ack, no-cache, with-listener and " "writer"); - regListener = new TallyListener(); + regListener = std::make_shared<TallyListener>(); createPooledRegion(regionNames[0], false, locatorsG, poolName, true, regListener, false); - regWriter = new TallyWriter(); + regWriter = std::make_shared<TallyWriter>(); setCacheWriter(regionNames[0], regWriter); } END_TASK_DEFINITION http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/integration-test/ThinClientLocalCacheLoader.hpp ---------------------------------------------------------------------- diff --git a/src/cppcache/integration-test/ThinClientLocalCacheLoader.hpp b/src/cppcache/integration-test/ThinClientLocalCacheLoader.hpp index aaa3b93..bb03832 100644 --- a/src/cppcache/integration-test/ThinClientLocalCacheLoader.hpp +++ b/src/cppcache/integration-test/ThinClientLocalCacheLoader.hpp @@ -45,13 +45,13 @@ class ThinClientTallyLoader : public TallyLoader { CacheablePtr load(const RegionPtr& rp, const CacheableKeyPtr& key, const UserDataPtr& aCallbackArgument) { - int32_t loadValue = dynCast<CacheableInt32Ptr>( + int32_t loadValue = std::dynamic_pointer_cast<CacheableInt32>( TallyLoader::load(rp, key, aCallbackArgument)) ->value(); char lstrvalue[32]; sprintf(lstrvalue, "%i", loadValue); CacheableStringPtr lreturnValue = CacheableString::create(lstrvalue); - if (key != NULLPTR && (NULL != rp->getAttributes()->getEndpoints() || + if (key != nullptr && (NULL != rp->getAttributes()->getEndpoints() || rp->getAttributes()->getPoolName() != NULL)) { LOGDEBUG("Putting the value (%s) for local region clients only ", lstrvalue); @@ -62,21 +62,21 @@ class ThinClientTallyLoader : public TallyLoader { void close(const RegionPtr& region) { LOG(" ThinClientTallyLoader::close() called"); - if (region != NULLPTR) { + if (region != nullptr) { LOGINFO(" Region %s is Destroyed = %d ", region->getName(), region->isDestroyed()); ASSERT(region->isDestroyed() == true, "region.isDestroyed should return true"); /* - if(region.ptr() != NULL && region.ptr()->getCache() != NULLPTR){ + if(region.get() != NULL && region.get()->getCache() != nullptr){ LOGINFO(" Cache Name is Closed = %d ", - region.ptr()->getCache()->isClosed()); + region.get()->getCache()->isClosed()); }else{ - LOGINFO(" regionPtr or cachePtr is NULLPTR"); + LOGINFO(" regionPtr or cachePtr is nullptr"); } */ } else { - LOGINFO(" region is NULLPTR"); + LOGINFO(" region is nullptr"); } } }; @@ -114,7 +114,7 @@ DUNIT_TASK_DEFINITION(CLIENT1, SetupClient) // Plugin the ThinClientTallyLoader to the Region. AttributesMutatorPtr attrMutatorPtr = regionPtr->getAttributesMutator(); - reg1Loader1 = new ThinClientTallyLoader(); + reg1Loader1 = std::make_shared<ThinClientTallyLoader>(); attrMutatorPtr->setCacheLoader(reg1Loader1); } END_TASK_DEFINITION @@ -122,9 +122,9 @@ END_TASK_DEFINITION DUNIT_TASK_DEFINITION(CLIENT1, InitClientEvents) { numLoads = 0; - regionPtr = NULLPTR; - dSysPtr = NULLPTR; - cachePtr = NULLPTR; + regionPtr = nullptr; + dSysPtr = nullptr; + cachePtr = nullptr; } END_TASK_DEFINITION @@ -135,7 +135,7 @@ DUNIT_TASK_DEFINITION(CLIENT1, testLoader) ASSERT(!regionPtr->containsKey(keyPtr), "Key should not have been found in region."); // now having the Callbacks set, lets call the loader - ASSERT(regionPtr->get(keyPtr) != NULLPTR, "Expected non null value"); + ASSERT(regionPtr->get(keyPtr) != nullptr, "Expected non null value"); RegionEntryPtr regEntryPtr = regionPtr->getEntry(keyPtr); CacheablePtr valuePtr = regEntryPtr->getValue(); http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/integration-test/ThinClientNotification.hpp ---------------------------------------------------------------------- diff --git a/src/cppcache/integration-test/ThinClientNotification.hpp b/src/cppcache/integration-test/ThinClientNotification.hpp index 1094697..3b35bc1 100644 --- a/src/cppcache/integration-test/ThinClientNotification.hpp +++ b/src/cppcache/integration-test/ThinClientNotification.hpp @@ -45,7 +45,7 @@ CacheHelper* cacheHelper = NULL; void initClient(const bool isthinClient) { if (cacheHelper == NULL) { cacheHelper = new CacheHelper(isthinClient, "__TEST_POOL1__", locatorsG, - "ServerGroup1", NULLPTR, 0, true); + "ServerGroup1", nullptr, 0, true); } ASSERT(cacheHelper, "Failed to create a CacheHelper client instance."); } @@ -81,7 +81,7 @@ void _verifyEntry(const char* name, const char* key, const char* val, free(buf); RegionPtr regPtr = getHelper()->getRegion(name); - ASSERT(regPtr != NULLPTR, "Region not found."); + ASSERT(regPtr != nullptr, "Region not found."); CacheableKeyPtr keyPtr = createKey(key); @@ -118,10 +118,9 @@ void _verifyEntry(const char* name, const char* key, const char* val, if (val != NULL) { LOG(" checkin val"); - CacheableStringPtr checkPtr = - dynCast<CacheableStringPtr>(regPtr->get(keyPtr)); + auto checkPtr = std::dynamic_pointer_cast<CacheableString>(regPtr->get(keyPtr)); - ASSERT(checkPtr != NULLPTR, "Value Ptr should not be null."); + ASSERT(checkPtr != nullptr, "Value Ptr should not be null."); char buf[1024]; sprintf(buf, "In verify loop, get returned %s for key %s", checkPtr->asChar(), key); @@ -179,7 +178,7 @@ void createPooledRegion(const char* name, bool ackMode, const char* locators, RegionPtr regPtr = getHelper()->createPooledRegion(name, ackMode, locators, poolname, cachingEnable, clientNotificationEnabled); - ASSERT(regPtr != NULLPTR, "Failed to create region."); + ASSERT(regPtr != nullptr, "Failed to create region."); LOG("Pooled Region created."); } @@ -193,7 +192,7 @@ void createEntry(const char* name, const char* key, const char* value) { CacheableStringPtr valPtr = CacheableString::create(value); RegionPtr regPtr = getHelper()->getRegion(name); - ASSERT(regPtr != NULLPTR, "Region not found."); + ASSERT(regPtr != nullptr, "Region not found."); ASSERT(!regPtr->containsKey(keyPtr), "Key should not have been found in region."); @@ -218,7 +217,7 @@ void updateEntry(const char* name, const char* key, const char* value) { CacheableStringPtr valPtr = CacheableString::create(value); RegionPtr regPtr = getHelper()->getRegion(name); - ASSERT(regPtr != NULLPTR, "Region not found."); + ASSERT(regPtr != nullptr, "Region not found."); ASSERT(regPtr->containsKey(keyPtr), "Key should have been found in region."); ASSERT(regPtr->containsValueForKey(keyPtr), @@ -244,7 +243,7 @@ void doNetsearch(const char* name, const char* key, const char* value) { RegionPtr regPtr = getHelper()->getRegion(name); fprintf(stdout, "netsearch region %s\n", regPtr->getName()); fflush(stdout); - ASSERT(regPtr != NULLPTR, "Region not found."); + ASSERT(regPtr != nullptr, "Region not found."); /*NIL: Changed the asserion due to the change in invalidate. Now we create new entery for every invalidate event received or localInvalidate call @@ -254,10 +253,9 @@ void doNetsearch(const char* name, const char* key, const char* value) { "Value should not have been found in region."); CacheablePtr theValue = regPtr->get(keyPtr); - CacheableStringPtr checkPtr = - dynCast<CacheableStringPtr>(theValue); // force a netsearch + auto checkPtr = std::dynamic_pointer_cast<CacheableString>(theValue); // force a netsearch - if (checkPtr != NULLPTR) { + if (checkPtr != nullptr) { LOG("checkPtr is not null"); char buf[1024]; sprintf(buf, "In net search, get returned %s for key %s", @@ -278,7 +276,7 @@ void invalidateEntry(const char* name, const char* key) { CacheableKeyPtr keyPtr = CacheableKey::create(key); RegionPtr regPtr = getHelper()->getRegion(name); - ASSERT(regPtr != NULLPTR, "Region not found."); + ASSERT(regPtr != nullptr, "Region not found."); ASSERT(regPtr->containsKey(keyPtr), "Key should have been found in region."); ASSERT(regPtr->containsValueForKey(keyPtr), @@ -299,7 +297,7 @@ void destroyEntry(const char* name, const char* key) { CacheableKeyPtr keyPtr = CacheableKey::create(key); RegionPtr regPtr = getHelper()->getRegion(name); - ASSERT(regPtr != NULLPTR, "Region not found."); + ASSERT(regPtr != nullptr, "Region not found."); ASSERT(regPtr->containsKey(keyPtr), "Key should have been found in region."); @@ -341,9 +339,9 @@ DUNIT_TASK_DEFINITION(CLIENT1, CreateRegions1_PoolLocators) true); createPooledRegion(regionNames[1], NO_ACK, locatorsG, "__TESTPOOL1_", true); RegionPtr regPtr = getHelper()->getRegion(regionNames[0]); - regPtr->registerAllKeys(false, NULLPTR, false, false); + regPtr->registerAllKeys(false, nullptr, false, false); regPtr = getHelper()->getRegion(regionNames[1]); - regPtr->registerAllKeys(false, NULLPTR, false, false); + regPtr->registerAllKeys(false, nullptr, false, false); LOG("CreateRegions1_PoolLocators complete."); } END_TASK_DEFINITION @@ -354,9 +352,9 @@ DUNIT_TASK_DEFINITION(CLIENT2, CreateRegions2_PoolLocators) true); createPooledRegion(regionNames[1], NO_ACK, locatorsG, "__TESTPOOL1_", true); RegionPtr regPtr = getHelper()->getRegion(regionNames[0]); - regPtr->registerAllKeys(false, NULLPTR, false, false); + regPtr->registerAllKeys(false, nullptr, false, false); regPtr = getHelper()->getRegion(regionNames[1]); - regPtr->registerAllKeys(false, NULLPTR, false, false); + regPtr->registerAllKeys(false, nullptr, false, false); LOG("CreateRegions2_PoolLocators complete."); } END_TASK_DEFINITION http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/integration-test/ThinClientPdxSerializer.hpp ---------------------------------------------------------------------- diff --git a/src/cppcache/integration-test/ThinClientPdxSerializer.hpp b/src/cppcache/integration-test/ThinClientPdxSerializer.hpp index 335a8c4..b7935ff 100644 --- a/src/cppcache/integration-test/ThinClientPdxSerializer.hpp +++ b/src/cppcache/integration-test/ThinClientPdxSerializer.hpp @@ -61,7 +61,7 @@ void initClient(const bool isthinClient, bool isPdxIgnoreUnreadFields) { LOGINFO("initClient: isPdxIgnoreUnreadFields = %d ", isPdxIgnoreUnreadFields); if (cacheHelper == NULL) { cacheHelper = new CacheHelper(isthinClient, isPdxIgnoreUnreadFields, false, - NULLPTR, false); + nullptr, false); } ASSERT(cacheHelper, "Failed to create a CacheHelper client instance."); } @@ -155,58 +155,55 @@ DUNIT_TASK_DEFINITION(CLIENT2, StepTwoPoolLoc_PDX) END_TASK_DEFINITION void checkPdxInstanceToStringAtServer(RegionPtr regionPtr) { - CacheableKeyPtr keyport = CacheableKey::create("success"); - CacheableBooleanPtr boolPtr = - dynCast<CacheableBooleanPtr>(regionPtr->get(keyport)); + auto keyport = CacheableKey::create("success"); + auto boolPtr = + std::dynamic_pointer_cast<CacheableBoolean>(regionPtr->get(keyport)); bool val = boolPtr->value(); ASSERT(val == true, "checkPdxInstanceToStringAtServer: Val should be true"); } DUNIT_TASK_DEFINITION(CLIENT1, JavaPutGet) { - Serializable::registerPdxSerializer( - PdxSerializerPtr(new TestPdxSerializer)); + Serializable::registerPdxSerializer(std::make_shared<TestPdxSerializer>()); - RegionPtr regPtr0 = getHelper()->getRegion("DistRegionAck"); + auto regPtr0 = getHelper()->getRegion("DistRegionAck"); - CacheableKeyPtr keyport = CacheableKey::create(1); + auto keyport = CacheableKey::create(1); - PdxTests::NonPdxType* npt1 = new PdxTests::NonPdxType; - PdxWrapperPtr pdxobj(new PdxWrapper(npt1, CLASSNAME1)); + auto npt1 = new PdxTests::NonPdxType; + auto pdxobj = std::make_shared<PdxWrapper>(npt1, CLASSNAME1); regPtr0->put(keyport, pdxobj); - PdxWrapperPtr obj2 = dynCast<PdxWrapperPtr>(regPtr0->get(keyport)); + auto obj2 = std::dynamic_pointer_cast<PdxWrapper>(regPtr0->get(keyport)); - CacheableBooleanPtr boolPtr = - dynCast<CacheableBooleanPtr>(regPtr0->get("success")); - bool isEqual = boolPtr.ptr()->value(); + auto boolPtr = + std::dynamic_pointer_cast<CacheableBoolean>(regPtr0->get("success")); + bool isEqual = boolPtr.get()->value(); ASSERT(isEqual == true, "Task JavaPutGet:Objects of type NonPdxType should be equal"); - PdxTests::NonPdxType* npt2 = - reinterpret_cast<PdxTests::NonPdxType*>(obj2->getObject()); + auto npt2 = reinterpret_cast<PdxTests::NonPdxType*>(obj2->getObject()); ASSERT(npt1->equals(*npt2, false), "NonPdxType compare"); } END_TASK_DEFINITION DUNIT_TASK_DEFINITION(CLIENT2, JavaGet) { - Serializable::registerPdxSerializer( - PdxSerializerPtr(new TestPdxSerializer)); + Serializable::registerPdxSerializer(std::make_shared<TestPdxSerializer>()); LOGDEBUG("JavaGet-1 Line_309"); - RegionPtr regPtr0 = getHelper()->getRegion("DistRegionAck"); + auto regPtr0 = getHelper()->getRegion("DistRegionAck"); - CacheableKeyPtr keyport1 = CacheableKey::create(1); + auto keyport1 = CacheableKey::create(1); LOGDEBUG("JavaGet-2 Line_314"); - PdxWrapperPtr obj1 = dynCast<PdxWrapperPtr>(regPtr0->get(keyport1)); - PdxTests::NonPdxType* npt1 ATTR_UNUSED = + auto obj1 = std::dynamic_pointer_cast<PdxWrapper>(regPtr0->get(keyport1)); + auto npt1 ATTR_UNUSED = reinterpret_cast<PdxTests::NonPdxType*>(obj1->getObject()); LOGDEBUG("JavaGet-3 Line_316"); - CacheableKeyPtr keyport2 = CacheableKey::create("putFromjava"); + auto keyport2 = CacheableKey::create("putFromjava"); LOGDEBUG("JavaGet-4 Line_316"); - PdxWrapperPtr obj2 = dynCast<PdxWrapperPtr>(regPtr0->get(keyport2)); - PdxTests::NonPdxType* npt2 ATTR_UNUSED = + auto obj2 = std::dynamic_pointer_cast<PdxWrapper>(regPtr0->get(keyport2)); + auto npt2 ATTR_UNUSED = reinterpret_cast<PdxTests::NonPdxType*>(obj2->getObject()); LOGDEBUG("JavaGet-5 Line_320"); } @@ -214,24 +211,25 @@ END_TASK_DEFINITION DUNIT_TASK_DEFINITION(CLIENT1, putFromVersion1_PS) { - RegionPtr regPtr0 = getHelper()->getRegion("DistRegionAck"); - CacheableKeyPtr key = CacheableKey::create(1); + auto regPtr0 = getHelper()->getRegion("DistRegionAck"); + auto key = CacheableKey::create(1); - PdxTests::TestDiffTypePdxSV1* npt1 = - new PdxTests::TestDiffTypePdxSV1(false); + // purpose? + // PdxTests::TestDiffTypePdxSV2* npt1 = + // new PdxTests::TestDiffTypePdxSV2(false); Serializable::registerPdxSerializer( - PdxSerializerPtr(new TestPdxSerializerForV1)); + std::make_shared<TestPdxSerializerForV1>()); - // Create New object and wrap it in PdxWrapper - npt1 = new PdxTests::TestDiffTypePdxSV1(true); - PdxWrapperPtr pdxobj(new PdxWrapper(npt1, V1CLASSNAME2)); + // Create New object and wrap it in PdxWrapper (owner) + auto npt1 = new PdxTests::TestDiffTypePdxSV1(true); + auto pdxobj = std::make_shared<PdxWrapper>(npt1, V1CLASSNAME2); // PUT regPtr0->put(key, pdxobj); // GET - PdxWrapperPtr obj2 = dynCast<PdxWrapperPtr>(regPtr0->get(key)); - PdxTests::TestDiffTypePdxSV1* npt2 = + auto obj2 = std::dynamic_pointer_cast<PdxWrapper>(regPtr0->get(key)); + auto npt2 = reinterpret_cast<PdxTests::TestDiffTypePdxSV1*>(obj2->getObject()); // Equal check @@ -245,24 +243,25 @@ END_TASK_DEFINITION DUNIT_TASK_DEFINITION(CLIENT2, putFromVersion2_PS) { - RegionPtr regPtr0 = getHelper()->getRegion("DistRegionAck"); - CacheableKeyPtr key = CacheableKey::create(1); + auto regPtr0 = getHelper()->getRegion("DistRegionAck"); + auto key = CacheableKey::create(1); - PdxTests::TestDiffTypePdxSV2* npt1 = - new PdxTests::TestDiffTypePdxSV2(false); + // purpose? + // PdxTests::TestDiffTypePdxSV2* npt1 = + // new PdxTests::TestDiffTypePdxSV2(false); Serializable::registerPdxSerializer( PdxSerializerPtr(new TestPdxSerializerForV2)); - // New object - npt1 = new PdxTests::TestDiffTypePdxSV2(true); - PdxWrapperPtr pdxobj(new PdxWrapper(npt1, V2CLASSNAME4)); + // Create New object and wrap it in PdxWrapper (owner) + auto npt1 = new PdxTests::TestDiffTypePdxSV2(true); + auto pdxobj = std::make_shared<PdxWrapper>(npt1, V2CLASSNAME4); // PUT regPtr0->put(key, pdxobj); // GET - PdxWrapperPtr obj2 = dynCast<PdxWrapperPtr>(regPtr0->get(key)); - PdxTests::TestDiffTypePdxSV2* npt2 = + auto obj2 = std::dynamic_pointer_cast<PdxWrapper>(regPtr0->get(key)); + auto npt2 = reinterpret_cast<PdxTests::TestDiffTypePdxSV2*>(obj2->getObject()); // Equal check @@ -272,23 +271,23 @@ DUNIT_TASK_DEFINITION(CLIENT2, putFromVersion2_PS) "Task putFromVersion2_PS:Objects of type TestPdxSerializerForV2 " "should be equal"); - CacheableKeyPtr key2 = CacheableKey::create(2); + auto key2 = CacheableKey::create(2); regPtr0->put(key2, pdxobj); } END_TASK_DEFINITION DUNIT_TASK_DEFINITION(CLIENT1, getputFromVersion1_PS) { - RegionPtr regPtr0 = getHelper()->getRegion("DistRegionAck"); - CacheableKeyPtr key = CacheableKey::create(1); + auto regPtr0 = getHelper()->getRegion("DistRegionAck"); + auto key = CacheableKey::create(1); // GET - PdxWrapperPtr obj2 = dynCast<PdxWrapperPtr>(regPtr0->get(key)); - PdxTests::TestDiffTypePdxSV1* npt2 = + auto obj2 = std::dynamic_pointer_cast<PdxWrapper>(regPtr0->get(key)); + auto npt2 = reinterpret_cast<PdxTests::TestDiffTypePdxSV1*>(obj2->getObject()); // Create New object and Compare - PdxTests::TestDiffTypePdxSV1* npt1 = new PdxTests::TestDiffTypePdxSV1(true); + auto npt1 = new PdxTests::TestDiffTypePdxSV1(true); bool isEqual = npt1->equals(npt2); LOGDEBUG("getputFromVersion1_PS-1 isEqual = %d", isEqual); ASSERT(isEqual == true, @@ -298,9 +297,9 @@ DUNIT_TASK_DEFINITION(CLIENT1, getputFromVersion1_PS) // PUT regPtr0->put(key, obj2); - CacheableKeyPtr key2 = CacheableKey::create(2); - obj2 = dynCast<PdxWrapperPtr>(regPtr0->get(key2)); - PdxTests::TestDiffTypePdxSV1* pRet = + auto key2 = CacheableKey::create(2); + obj2 = std::dynamic_pointer_cast<PdxWrapper>(regPtr0->get(key2)); + auto pRet = reinterpret_cast<PdxTests::TestDiffTypePdxSV1*>(obj2->getObject()); isEqual = npt1->equals(pRet); LOGDEBUG("getputFromVersion1_PS-2 isEqual = %d", isEqual); @@ -309,22 +308,22 @@ DUNIT_TASK_DEFINITION(CLIENT1, getputFromVersion1_PS) "should be equal"); // Get then Put.. this should Not merge data back - PdxWrapperPtr pdxobj = PdxWrapperPtr(new PdxWrapper(npt1, V1CLASSNAME2)); + auto pdxobj = std::make_shared<PdxWrapper>(npt1, V1CLASSNAME2); regPtr0->put(key2, pdxobj); } END_TASK_DEFINITION DUNIT_TASK_DEFINITION(CLIENT2, getAtVersion2_PS) { - RegionPtr regPtr0 = getHelper()->getRegion("DistRegionAck"); - CacheableKeyPtr key = CacheableKey::create(1); + auto regPtr0 = getHelper()->getRegion("DistRegionAck"); + auto key = CacheableKey::create(1); // New object - PdxTests::TestDiffTypePdxSV2* np = new PdxTests::TestDiffTypePdxSV2(true); + auto np = new PdxTests::TestDiffTypePdxSV2(true); // GET - PdxWrapperPtr obj2 = dynCast<PdxWrapperPtr>(regPtr0->get(key)); - PdxTests::TestDiffTypePdxSV2* pRet = + auto obj2 = std::dynamic_pointer_cast<PdxWrapper>(regPtr0->get(key)); + auto pRet = reinterpret_cast<PdxTests::TestDiffTypePdxSV2*>(obj2->getObject()); bool isEqual = np->equals(pRet); @@ -334,10 +333,10 @@ DUNIT_TASK_DEFINITION(CLIENT2, getAtVersion2_PS) "Task getAtVersion2_PS:Objects of type TestPdxSerializerForV2 should " "be equal"); - CacheableKeyPtr key2 = CacheableKey::create(2); + auto key2 = CacheableKey::create(2); np = new PdxTests::TestDiffTypePdxSV2(true); - obj2 = dynCast<PdxWrapperPtr>(regPtr0->get(key2)); + obj2 = std::dynamic_pointer_cast<PdxWrapper>(regPtr0->get(key2)); pRet = reinterpret_cast<PdxTests::TestDiffTypePdxSV2*>(obj2->getObject()); isEqual = np->equals(pRet); http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/integration-test/ThinClientPdxSerializers.hpp ---------------------------------------------------------------------- diff --git a/src/cppcache/integration-test/ThinClientPdxSerializers.hpp b/src/cppcache/integration-test/ThinClientPdxSerializers.hpp index 834c8bf..f9ef18e 100644 --- a/src/cppcache/integration-test/ThinClientPdxSerializers.hpp +++ b/src/cppcache/integration-test/ThinClientPdxSerializers.hpp @@ -106,21 +106,26 @@ class TestPdxSerializer : public PdxSerializer { npt->m_byteArray = pr->readByteArray("m_byteArray", npt->byteArrayLen); npt->m_charArray = pr->readCharArray("m_charArray", npt->charArrayLen); - npt->m_arraylist = pr->readObject("m_arraylist"); + npt->m_arraylist = std::dynamic_pointer_cast<CacheableArrayList>( + pr->readObject("m_arraylist")); - npt->m_map = dynCast<CacheableHashMapPtr>(pr->readObject("m_map")); + npt->m_map = std::dynamic_pointer_cast<CacheableHashMap>(pr->readObject("m_map")); // TODO:Check for the size - npt->m_hashtable = pr->readObject("m_hashtable"); + npt->m_hashtable = std::dynamic_pointer_cast<CacheableHashTable>( + pr->readObject("m_hashtable")); // TODO:Check for the size - npt->m_vector = pr->readObject("m_vector"); + npt->m_vector = std::dynamic_pointer_cast<CacheableVector>( + pr->readObject("m_vector")); // TODO::Check for size - npt->m_chs = pr->readObject("m_chs"); + npt->m_chs = + std::dynamic_pointer_cast<CacheableHashSet>(pr->readObject("m_chs")); // TODO::Size check - npt->m_clhs = pr->readObject("m_clhs"); + npt->m_clhs = std::dynamic_pointer_cast<CacheableLinkedHashSet>( + pr->readObject("m_clhs")); // TODO:Size check npt->m_string = pr->readString("m_string"); // GenericValCompare http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/integration-test/ThinClientPutAll.hpp ---------------------------------------------------------------------- diff --git a/src/cppcache/integration-test/ThinClientPutAll.hpp b/src/cppcache/integration-test/ThinClientPutAll.hpp index 9db38ee..4fd8044 100644 --- a/src/cppcache/integration-test/ThinClientPutAll.hpp +++ b/src/cppcache/integration-test/ThinClientPutAll.hpp @@ -91,7 +91,7 @@ void _verifyEntry(const char* name, const char* key, const char* val, free(buf); RegionPtr regPtr = getHelper()->getRegion(name); - ASSERT(regPtr != NULLPTR, "Region not found."); + ASSERT(regPtr != nullptr, "Region not found."); CacheableKeyPtr keyPtr = createKey(key); @@ -140,10 +140,10 @@ void _verifyEntry(const char* name, const char* key, const char* val, } if (val != NULL) { - CacheableStringPtr checkPtr = - dynCast<CacheableStringPtr>(regPtr->get(keyPtr)); + auto checkPtr = + std::dynamic_pointer_cast<CacheableString>(regPtr->get(keyPtr)); - ASSERT(checkPtr != NULLPTR, "Value Ptr should not be null."); + ASSERT(checkPtr != nullptr, "Value Ptr should not be null."); char buf[1024]; sprintf(buf, "In verify loop, get returned %s for key %s", checkPtr->asChar(), key); @@ -206,8 +206,8 @@ void createRegion(const char* name, bool ackMode, bool isCacheEnabled, fprintf(stdout, "Creating region -- %s ackMode is %d\n", name, ackMode); fflush(stdout); RegionPtr regPtr = getHelper()->createRegion( - name, ackMode, isCacheEnabled, NULLPTR, clientNotificationEnabled); - ASSERT(regPtr != NULLPTR, "Failed to create region."); + name, ackMode, isCacheEnabled, nullptr, clientNotificationEnabled); + ASSERT(regPtr != nullptr, "Failed to create region."); LOG("Region created."); } void createPooledRegion(const char* name, bool ackMode, const char* locators, @@ -220,7 +220,7 @@ void createPooledRegion(const char* name, bool ackMode, const char* locators, RegionPtr regPtr = getHelper()->createPooledRegion(name, ackMode, locators, poolname, cachingEnable, clientNotificationEnabled); - ASSERT(regPtr != NULLPTR, "Failed to create region."); + ASSERT(regPtr != nullptr, "Failed to create region."); LOG("Pooled Region created."); } @@ -234,7 +234,7 @@ void createPooledRegionConcurrencyCheckDisabled( RegionPtr regPtr = getHelper()->createPooledRegionConcurrencyCheckDisabled( name, ackMode, locators, poolname, cachingEnable, clientNotificationEnabled, concurrencyCheckEnabled); - ASSERT(regPtr != NULLPTR, "Failed to create region."); + ASSERT(regPtr != nullptr, "Failed to create region."); LOG("Pooled Region created."); } @@ -251,7 +251,7 @@ void createEntry(const char* name, const char* key, const char* value = NULL) { CacheableStringPtr valPtr = CacheableString::create(value); RegionPtr regPtr = getHelper()->getRegion(name); - ASSERT(regPtr != NULLPTR, "Region not found."); + ASSERT(regPtr != nullptr, "Region not found."); ASSERT(!regPtr->containsKey(keyPtr), "Key should not have been found in region."); @@ -276,7 +276,7 @@ void updateEntry(const char* name, const char* key, const char* value) { CacheableStringPtr valPtr = CacheableString::create(value); RegionPtr regPtr = getHelper()->getRegion(name); - ASSERT(regPtr != NULLPTR, "Region not found."); + ASSERT(regPtr != nullptr, "Region not found."); ASSERT(regPtr->containsKey(keyPtr), "Key should have been found in region."); ASSERT(regPtr->containsValueForKey(keyPtr), @@ -302,17 +302,17 @@ void doNetsearch(const char* name, const char* key, const char* value) { RegionPtr regPtr = getHelper()->getRegion(name); fprintf(stdout, "netsearch region %s\n", regPtr->getName()); fflush(stdout); - ASSERT(regPtr != NULLPTR, "Region not found."); + ASSERT(regPtr != nullptr, "Region not found."); ASSERT(!regPtr->containsKey(keyPtr), "Key should not have been found in region."); ASSERT(!regPtr->containsValueForKey(keyPtr), "Value should not have been found in region."); - CacheableStringPtr checkPtr = - dynCast<CacheableStringPtr>(regPtr->get(keyPtr)); // force a netsearch + auto checkPtr = std::dynamic_pointer_cast<CacheableString>( + regPtr->get(keyPtr)); // force a netsearch - if (checkPtr != NULLPTR) { + if (checkPtr != nullptr) { LOG("checkPtr is not null"); char buf[1024]; sprintf(buf, "In net search, get returned %s for key %s", @@ -414,7 +414,7 @@ DUNIT_TASK_DEFINITION(CLIENT1, StepThree) VectorOfCacheableKey keys1; keys1.push_back(keyPtr0); keys1.push_back(keyPtr1); - regPtr0->registerKeys(keys1, NULLPTR); + regPtr0->registerKeys(keys1); CacheableKeyPtr keyPtr2 = CacheableKey::create(keys[2]); CacheableKeyPtr keyPtr3 = CacheableKey::create(keys[3]); @@ -422,7 +422,7 @@ DUNIT_TASK_DEFINITION(CLIENT1, StepThree) VectorOfCacheableKey keys2; keys2.push_back(keyPtr2); keys2.push_back(keyPtr3); - regPtr1->registerKeys(keys2, NULLPTR); + regPtr1->registerKeys(keys2); LOG("StepThree complete."); } @@ -482,9 +482,9 @@ DUNIT_TASK_DEFINITION(CLIENT1, PutAllOps) getAllkeys.push_back(CacheableKey::create(key)); } - HashMapOfCacheablePtr valuesMap(new HashMapOfCacheable()); + auto valuesMap = std::make_shared<HashMapOfCacheable>(); valuesMap->clear(); - regPtr0->getAll(getAllkeys, valuesMap, NULLPTR, false); + regPtr0->getAll(getAllkeys, valuesMap, nullptr, false); ASSERT(valuesMap->size() == 500, "GetAll should return 2 entries."); LOG("PutAllOps complete."); @@ -588,11 +588,11 @@ DUNIT_TASK_DEFINITION(CLIENT1, StepTen) RegionPtr regPtr0 = getHelper()->getRegion(regionNames[0]); RegionServicePtr rsp = regPtr0->getRegionService(); RegionPtr regPtr = rsp->getRegion(regionNames[0]); - ASSERT(regPtr != NULLPTR, "Failed to get region."); + ASSERT(regPtr != nullptr, "Failed to get region."); RegionServicePtr rsp1 = regPtr0->getRegionService(); RegionPtr regPtr1 = rsp1->getRegion("NOT_CREATED_REGION"); - ASSERT(regPtr1 == NULLPTR, "Unknown Region Returned"); + ASSERT(regPtr1 == nullptr, "Unknown Region Returned"); LOG("StepTen complete."); } @@ -606,20 +606,20 @@ DUNIT_TASK_DEFINITION(CLIENT1, StepEleven) RegionPtr regPtr0 = getHelper()->getRegion(regionNames[0]); regPtr0->put(keyPtr0, valPtr0); - CacheableInt64Ptr checkPtr = - dynCast<CacheableInt64Ptr>(regPtr0->get(keyPtr0)); - ASSERT(checkPtr != NULLPTR, "checkPtr should not be null."); + auto checkPtr = + std::dynamic_pointer_cast<CacheableInt64>(regPtr0->get(keyPtr0)); + ASSERT(checkPtr != nullptr, "checkPtr should not be null."); regPtr0->invalidate(keyPtr0); - checkPtr = dynCast<CacheableInt64Ptr>(regPtr0->get(keyPtr0)); - ASSERT(checkPtr == NULLPTR, "checkPtr should be null."); + checkPtr = std::dynamic_pointer_cast<CacheableInt64>(regPtr0->get(keyPtr0)); + ASSERT(checkPtr == nullptr, "checkPtr should be null."); try { CacheableKeyPtr key; regPtr0->invalidate(key); - FAIL("Invalidate on NULLPTR should throw exception"); + FAIL("Invalidate on nullptr should throw exception"); } catch (IllegalArgumentException e) { - LOG(" Got an expected exception invalidate on NULLPTR should be throwing " + LOG(" Got an expected exception invalidate on nullptr should be throwing " "exception "); } @@ -636,8 +636,8 @@ DUNIT_TASK_DEFINITION(CLIENT1, StepThirteen) } regPtr0->putAll(map0); for (int i = 0; i < 2; i++) { - CacheableInt64Ptr checkPtr = - dynCast<CacheableInt64Ptr>(regPtr0->get(CacheableInt64::create(i))); + auto checkPtr = std::dynamic_pointer_cast<CacheableInt32>( + regPtr0->get(CacheableInt64::create(i))); ASSERT(checkPtr->value() == i, "putAll entry with long key and long value Mismatch."); } @@ -650,29 +650,30 @@ DUNIT_TASK_DEFINITION(CLIENT1, StepThirteen) } regPtr0->putAll(map0); for (int i = 80; i < 82; i++) { - CacheableStringPtr checkPtr = - dynCast<CacheableStringPtr>(regPtr0->get(CacheableInt64::create(i))); + auto checkPtr = std::dynamic_pointer_cast<CacheableString>( + regPtr0->get(CacheableInt64::create(i))); ASSERT(strcmp(checkPtr->asChar(), vals[i - 80]) == 0, "putAll entry with long key and string value Mismatch"); } map0.clear(); - PdxTests::PdxTypes1Ptr val111(new PdxTests::PdxTypes1()); + auto val111 = std::make_shared<PdxTests::PdxTypes1>(); map0.insert(CacheableInt32::create(1211), val111); regPtr0->putAll(map0); - PdxTests::PdxTypes1Ptr retObj = dynCast<PdxTests::PdxTypes1Ptr>( + auto retObj = std::dynamic_pointer_cast<PdxTests::PdxTypes1>( regPtr0->get(CacheableInt32::create(1211))); ASSERT(val111->equals(retObj) == true, "val111 and retObj should match."); map0.clear(); - CacheableKeyPtr keyObject(new PdxTests::PdxType()); + auto keyObject = std::make_shared<PdxTests::PdxType>(); map0.insert(keyObject, CacheableInt32::create(111)); regPtr0->putAll(map0); - CacheableInt32Ptr checkPtr = regPtr0->get(keyObject); + auto checkPtr = + std::dynamic_pointer_cast<CacheableInt32>(regPtr0->get(keyObject)); ASSERT(checkPtr->value() == 111, "putAll with entry as object key and value as int Mismatch"); map0.clear(); - CacheableKeyPtr keyObject6(new PdxTests::PdxTypes3()); + auto keyObject6 = std::make_shared<PdxTests::PdxTypes3>(); map0.insert(keyObject6, CacheableString::create("testString")); regPtr0->putAll(map0); CacheablePtr checkPtr1 = regPtr0->get(keyObject6); @@ -680,23 +681,23 @@ DUNIT_TASK_DEFINITION(CLIENT1, StepThirteen) "strVal should be testString."); map0.clear(); - CacheableKeyPtr keyObject7(new PdxTests::PdxTypes2()); - PdxTests::PdxTypes1Ptr valObject(new PdxTests::PdxTypes1()); - CacheableKeyPtr keyObject8(new PdxTests::PdxTypes2()); - PdxTests::PdxTypes1Ptr valObject2(new PdxTests::PdxTypes1()); + auto keyObject7 = std::make_shared<PdxTests::PdxTypes2>(); + auto valObject = std::make_shared<PdxTests::PdxTypes1>(); + auto keyObject8 = std::make_shared<PdxTests::PdxTypes2>(); + auto valObject2 = std::make_shared<PdxTests::PdxTypes1>(); map0.insert(keyObject7, valObject); map0.insert(keyObject8, valObject2); regPtr0->putAll(map0); - PdxTests::PdxTypes1Ptr objVal = - dynCast<PdxTests::PdxTypes1Ptr>(regPtr0->get(keyObject7)); + auto objVal = std::dynamic_pointer_cast<PdxTests::PdxTypes1>( + regPtr0->get(keyObject7)); ASSERT(valObject == objVal, "valObject and objVal should match."); map0.clear(); try { map0.insert(CacheableInt64::create(345), CacheableInt64::create(3465987)); regPtr0->putAll(map0, -1); - CacheableInt64Ptr checkPtr = - dynCast<CacheableInt64Ptr>(regPtr0->get(CacheableInt64::create(345))); + auto checkPtr = std::dynamic_pointer_cast<CacheableInt64>( + regPtr0->get(CacheableInt64::create(345))); ASSERT(checkPtr->value() == 3465987, "putAll entry with long key and long value Mismatch."); } catch (Exception& excp) { @@ -713,7 +714,7 @@ DUNIT_TASK_DEFINITION(CLIENT1, StepThirteen) map0.insert(CacheableInt64::create(3451), CacheableInt64::create(3465987)); regPtr0->putAll(map0, 2147500); - CacheableInt64Ptr checkPtr = dynCast<CacheableInt64Ptr>( + auto checkPtr = std::dynamic_pointer_cast<CacheableInt64>( regPtr0->get(CacheableInt64::create(3451))); ASSERT(checkPtr->value() == 3465987, "putAll entry with long key and long value Mismatch."); @@ -732,17 +733,17 @@ DUNIT_TASK_DEFINITION(CLIENT1, StepThirteen) VectorOfCacheableKey keys1; keys1.push_back(keyObject7); keys1.push_back(keyObject8); - HashMapOfCacheablePtr valuesMap(new HashMapOfCacheable()); + auto valuesMap = std::make_shared<HashMapOfCacheable>(); valuesMap->clear(); - regPtr0->getAll(keys1, valuesMap, NULLPTR, true); + regPtr0->getAll(keys1, valuesMap, nullptr, true); if (valuesMap->size() == keys1.size()) { char buf[2048]; for (HashMapOfCacheable::Iterator iter = valuesMap->begin(); iter != valuesMap->end(); iter++) { - CacheableKeyPtr key = dynCast<CacheableKeyPtr>(iter.first()); + auto key = std::dynamic_pointer_cast<CacheableKey>(iter.first()); CacheablePtr mVal = iter.second(); - if (mVal != NULLPTR) { - PdxTests::PdxTypes1Ptr val1 = dynCast<PdxTests::PdxTypes1Ptr>(mVal); + if (mVal != nullptr) { + auto val1 = std::dynamic_pointer_cast<PdxTests::PdxTypes1>(mVal); sprintf(buf, "value from map %d , expected value %d ", val1->getm_i1(), 34324); LOG(buf); @@ -757,9 +758,9 @@ DUNIT_TASK_DEFINITION(CLIENT1, StepThirteen) } regPtr0->putAll(map2); for (int i = 100; i < 102; i++) { - CacheablePtr checkPtr = dynCast<CacheablePtr>( regPtr0->get( + auto checkPtr = std::dynamic_pointer_cast<Cacheable>( regPtr0->get( CacheableString::create(vals[i - 100])) ); - if ( checkPtr != NULLPTR ) { + if ( checkPtr != nullptr ) { FAIL ("putAll with entry cacheable key and null value Mismatch"); } }*/ http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/integration-test/ThinClientPutAllWithCallBack.hpp ---------------------------------------------------------------------- diff --git a/src/cppcache/integration-test/ThinClientPutAllWithCallBack.hpp b/src/cppcache/integration-test/ThinClientPutAllWithCallBack.hpp index dffb51f..9427b24 100644 --- a/src/cppcache/integration-test/ThinClientPutAllWithCallBack.hpp +++ b/src/cppcache/integration-test/ThinClientPutAllWithCallBack.hpp @@ -90,7 +90,7 @@ void _verifyEntry(const char* name, const char* key, const char* val, } RegionPtr regPtr = getHelper()->getRegion(name); - ASSERT(regPtr != NULLPTR, "Region not found."); + ASSERT(regPtr != nullptr, "Region not found."); CacheableKeyPtr keyPtr = createKey(key); @@ -139,10 +139,10 @@ void _verifyEntry(const char* name, const char* key, const char* val, } if (val != NULL) { - CacheableStringPtr checkPtr = - dynCast<CacheableStringPtr>(regPtr->get(keyPtr)); + auto checkPtr = + std::dynamic_pointer_cast<CacheableString>(regPtr->get(keyPtr)); - ASSERT(checkPtr != NULLPTR, "Value Ptr should not be null."); + ASSERT(checkPtr != nullptr, "Value Ptr should not be null."); char buf[1024]; sprintf(buf, "In verify loop, get returned %s for key %s", checkPtr->asChar(), key); @@ -205,8 +205,8 @@ void createRegion(const char* name, bool ackMode, bool isCacheEnabled, fprintf(stdout, "Creating region -- %s ackMode is %d\n", name, ackMode); fflush(stdout); RegionPtr regPtr = getHelper()->createRegion( - name, ackMode, isCacheEnabled, NULLPTR, clientNotificationEnabled); - ASSERT(regPtr != NULLPTR, "Failed to create region."); + name, ackMode, isCacheEnabled, nullptr, clientNotificationEnabled); + ASSERT(regPtr != nullptr, "Failed to create region."); LOG("Region created."); } void createPooledRegion(const char* name, bool ackMode, const char* locators, @@ -219,7 +219,7 @@ void createPooledRegion(const char* name, bool ackMode, const char* locators, RegionPtr regPtr = getHelper()->createPooledRegion(name, ackMode, locators, poolname, cachingEnable, clientNotificationEnabled); - ASSERT(regPtr != NULLPTR, "Failed to create region."); + ASSERT(regPtr != nullptr, "Failed to create region."); LOG("Pooled Region created."); } @@ -233,7 +233,7 @@ void createPooledRegionConcurrencyCheckDisabled( RegionPtr regPtr = getHelper()->createPooledRegionConcurrencyCheckDisabled( name, ackMode, locators, poolname, cachingEnable, clientNotificationEnabled, concurrencyCheckEnabled); - ASSERT(regPtr != NULLPTR, "Failed to create region."); + ASSERT(regPtr != nullptr, "Failed to create region."); LOG("Pooled Region created."); } @@ -250,7 +250,7 @@ void createEntry(const char* name, const char* key, const char* value = NULL) { CacheableStringPtr valPtr = CacheableString::create(value); RegionPtr regPtr = getHelper()->getRegion(name); - ASSERT(regPtr != NULLPTR, "Region not found."); + ASSERT(regPtr != nullptr, "Region not found."); ASSERT(!regPtr->containsKey(keyPtr), "Key should not have been found in region."); @@ -275,7 +275,7 @@ void updateEntry(const char* name, const char* key, const char* value) { CacheableStringPtr valPtr = CacheableString::create(value); RegionPtr regPtr = getHelper()->getRegion(name); - ASSERT(regPtr != NULLPTR, "Region not found."); + ASSERT(regPtr != nullptr, "Region not found."); ASSERT(regPtr->containsKey(keyPtr), "Key should have been found in region."); ASSERT(regPtr->containsValueForKey(keyPtr), @@ -301,17 +301,17 @@ void doNetsearch(const char* name, const char* key, const char* value) { RegionPtr regPtr = getHelper()->getRegion(name); fprintf(stdout, "netsearch region %s\n", regPtr->getName()); fflush(stdout); - ASSERT(regPtr != NULLPTR, "Region not found."); + ASSERT(regPtr != nullptr, "Region not found."); ASSERT(!regPtr->containsKey(keyPtr), "Key should not have been found in region."); ASSERT(!regPtr->containsValueForKey(keyPtr), "Value should not have been found in region."); - CacheableStringPtr checkPtr = - dynCast<CacheableStringPtr>(regPtr->get(keyPtr)); // force a netsearch + auto checkPtr = std::dynamic_pointer_cast<CacheableString>( + regPtr->get(keyPtr)); // force a netsearch - if (checkPtr != NULLPTR) { + if (checkPtr != nullptr) { LOG("checkPtr is not null"); char buf[1024]; sprintf(buf, "In net search, get returned %s for key %s", @@ -416,7 +416,7 @@ DUNIT_TASK_DEFINITION(CLIENT1, RegisterClient1Keys) VectorOfCacheableKey keys1; keys1.push_back(keyPtr0); keys1.push_back(keyPtr1); - regPtr0->registerKeys(keys1, NULLPTR); + regPtr0->registerKeys(keys1); CacheableKeyPtr keyPtr2 = CacheableKey::create(keys[2]); CacheableKeyPtr keyPtr3 = CacheableKey::create(keys[3]); @@ -424,7 +424,7 @@ DUNIT_TASK_DEFINITION(CLIENT1, RegisterClient1Keys) VectorOfCacheableKey keys2; keys2.push_back(keyPtr2); keys2.push_back(keyPtr3); - regPtr1->registerKeys(keys2, NULLPTR); + regPtr1->registerKeys(keys2); LOG("RegisterClient1Keys complete."); } @@ -485,9 +485,9 @@ DUNIT_TASK_DEFINITION(CLIENT1, PutAllOps) getAllkeys.push_back(CacheableKey::create(key)); } - HashMapOfCacheablePtr valuesMap(new HashMapOfCacheable()); + auto valuesMap = std::make_shared<HashMapOfCacheable>(); valuesMap->clear(); - regPtr0->getAll(getAllkeys, valuesMap, NULLPTR, false); + regPtr0->getAll(getAllkeys, valuesMap, nullptr, false); ASSERT(valuesMap->size() == 500, "GetAll should return 500 entries."); LOG("PutAllOps complete."); @@ -591,11 +591,11 @@ DUNIT_TASK_DEFINITION(CLIENT1, VerifyRegionService) RegionPtr regPtr0 = getHelper()->getRegion(regionNames[0]); RegionServicePtr rsp = regPtr0->getRegionService(); RegionPtr regPtr = rsp->getRegion(regionNames[0]); - ASSERT(regPtr != NULLPTR, "Failed to get region."); + ASSERT(regPtr != nullptr, "Failed to get region."); RegionServicePtr rsp1 = regPtr0->getRegionService(); RegionPtr regPtr1 = rsp1->getRegion("NOT_CREATED_REGION"); - ASSERT(regPtr1 == NULLPTR, "Unknown Region Returned"); + ASSERT(regPtr1 == nullptr, "Unknown Region Returned"); LOG("VerifyRegionService complete."); } @@ -609,20 +609,20 @@ DUNIT_TASK_DEFINITION(CLIENT1, InvalidateKeys) RegionPtr regPtr0 = getHelper()->getRegion(regionNames[0]); regPtr0->put(keyPtr0, valPtr0); - CacheableInt64Ptr checkPtr = - dynCast<CacheableInt64Ptr>(regPtr0->get(keyPtr0)); - ASSERT(checkPtr != NULLPTR, "checkPtr should not be null."); + auto checkPtr = + std::dynamic_pointer_cast<CacheableInt64>(regPtr0->get(keyPtr0)); + ASSERT(checkPtr != nullptr, "checkPtr should not be null."); regPtr0->invalidate(keyPtr0); - checkPtr = dynCast<CacheableInt64Ptr>(regPtr0->get(keyPtr0)); - ASSERT(checkPtr == NULLPTR, "checkPtr should be null."); + checkPtr = std::dynamic_pointer_cast<CacheableInt64>(regPtr0->get(keyPtr0)); + ASSERT(checkPtr == nullptr, "checkPtr should be null."); try { CacheableKeyPtr key; regPtr0->invalidate(key); - FAIL("Invalidate on NULLPTR should throw exception"); + FAIL("Invalidate on nullptr should throw exception"); } catch (IllegalArgumentException e) { - LOG(" Got an expected exception invalidate on NULLPTR should be throwing " + LOG(" Got an expected exception invalidate on nullptr should be throwing " "exception "); } @@ -639,8 +639,8 @@ DUNIT_TASK_DEFINITION(CLIENT1, VerifyPutAllWithLongKeyAndStringValue) } regPtr0->putAll(map0, 15, CacheableInt32::create(1000)); for (int i = 0; i < 2; i++) { - CacheableInt64Ptr checkPtr = - dynCast<CacheableInt64Ptr>(regPtr0->get(CacheableInt64::create(i))); + auto checkPtr = std::dynamic_pointer_cast<CacheableInt64>( + regPtr0->get(CacheableInt64::create(i))); ASSERT(checkPtr->value() == i, "putAll entry with long key and long value Mismatch."); } @@ -653,8 +653,8 @@ DUNIT_TASK_DEFINITION(CLIENT1, VerifyPutAllWithLongKeyAndStringValue) } regPtr0->putAll(map0, 15, CacheableInt32::create(1000)); for (int i = 80; i < 82; i++) { - CacheableStringPtr checkPtr = - dynCast<CacheableStringPtr>(regPtr0->get(CacheableInt64::create(i))); + auto checkPtr = std::dynamic_pointer_cast<CacheableString>( + regPtr0->get(CacheableInt64::create(i))); ASSERT(strcmp(checkPtr->asChar(), vals[i - 80]) == 0, "putAll entry with long key and string value Mismatch"); } @@ -670,8 +670,8 @@ DUNIT_TASK_DEFINITION(CLIENT1, VerifyPutAllWithLongKeyAndLongValue) try { map0.insert(CacheableInt64::create(345), CacheableInt64::create(3465987)); regPtr0->putAll(map0, -1, CacheableInt32::create(1000)); - CacheableInt64Ptr checkPtr = - dynCast<CacheableInt64Ptr>(regPtr0->get(CacheableInt64::create(345))); + auto checkPtr = std::dynamic_pointer_cast<CacheableInt64>( + regPtr0->get(CacheableInt64::create(345))); ASSERT(checkPtr->value() == 3465987, "putAll entry with long key and long value Mismatch."); } catch (Exception& excp) { @@ -688,7 +688,7 @@ DUNIT_TASK_DEFINITION(CLIENT1, VerifyPutAllWithLongKeyAndLongValue) map0.insert(CacheableInt64::create(3451), CacheableInt64::create(3465987)); regPtr0->putAll(map0, 2147500, CacheableInt32::create(1000)); - CacheableInt64Ptr checkPtr = dynCast<CacheableInt64Ptr>( + auto checkPtr = std::dynamic_pointer_cast<CacheableInt64>( regPtr0->get(CacheableInt64::create(3451))); ASSERT(checkPtr->value() == 3465987, "putAll entry with long key and long value Mismatch."); @@ -709,22 +709,23 @@ DUNIT_TASK_DEFINITION(CLIENT1, VerifyPutAllWithObjectKey) { RegionPtr regPtr0 = getHelper()->getRegion(regionNames[0]); HashMapOfCacheable map0; - PdxTests::PdxTypes1Ptr val111(new PdxTests::PdxTypes1()); + auto val111 = std::make_shared<PdxTests::PdxTypes1>(); map0.insert(CacheableInt32::create(1211), val111); regPtr0->putAll(map0, 15, CacheableInt32::create(1000)); - PdxTests::PdxTypes1Ptr retObj = dynCast<PdxTests::PdxTypes1Ptr>( + auto retObj = std::dynamic_pointer_cast<PdxTests::PdxTypes1>( regPtr0->get(CacheableInt32::create(1211))); ASSERT(val111->equals(retObj) == true, "val111 and retObj should match."); map0.clear(); - CacheableKeyPtr keyObject(new PdxTests::PdxType()); + auto keyObject = std::make_shared<PdxTests::PdxType>(); map0.insert(keyObject, CacheableInt32::create(111)); regPtr0->putAll(map0, 15, CacheableInt32::create(1000)); - CacheableInt32Ptr checkPtr = regPtr0->get(keyObject); + CacheableInt32Ptr checkPtr = + std::dynamic_pointer_cast<CacheableInt32>(regPtr0->get(keyObject)); ASSERT(checkPtr->value() == 111, "putAll with entry as object key and value as int Mismatch"); map0.clear(); - CacheableKeyPtr keyObject6(new PdxTests::PdxTypes3()); + auto keyObject6 = std::make_shared<PdxTests::PdxTypes3>(); map0.insert(keyObject6, CacheableString::create("testString")); regPtr0->putAll(map0, 15, CacheableInt32::create(1000)); CacheablePtr checkPtr1 = regPtr0->get(keyObject6); @@ -732,15 +733,15 @@ DUNIT_TASK_DEFINITION(CLIENT1, VerifyPutAllWithObjectKey) "strVal should be testString."); map0.clear(); - CacheableKeyPtr keyObject7(new PdxTests::PdxTypes2()); - PdxTests::PdxTypes1Ptr valObject(new PdxTests::PdxTypes1()); - CacheableKeyPtr keyObject8(new PdxTests::PdxTypes2()); - PdxTests::PdxTypes1Ptr valObject2(new PdxTests::PdxTypes1()); + auto keyObject7 = std::make_shared<PdxTests::PdxTypes2>(); + auto valObject = std::make_shared<PdxTests::PdxTypes1>(); + auto keyObject8 = std::make_shared<PdxTests::PdxTypes2>(); + auto valObject2 = std::make_shared<PdxTests::PdxTypes1>(); map0.insert(keyObject7, valObject); map0.insert(keyObject8, valObject2); regPtr0->putAll(map0, 15, CacheableInt32::create(1000)); - PdxTests::PdxTypes1Ptr objVal = - dynCast<PdxTests::PdxTypes1Ptr>(regPtr0->get(keyObject7)); + auto objVal = std::dynamic_pointer_cast<PdxTests::PdxTypes1>( + regPtr0->get(keyObject7)); ASSERT(valObject == objVal, "valObject and objVal should match."); regPtr0->localInvalidateRegion(); @@ -748,17 +749,17 @@ DUNIT_TASK_DEFINITION(CLIENT1, VerifyPutAllWithObjectKey) VectorOfCacheableKey keys1; keys1.push_back(keyObject7); keys1.push_back(keyObject8); - HashMapOfCacheablePtr valuesMap(new HashMapOfCacheable()); + auto valuesMap = std::make_shared<HashMapOfCacheable>(); valuesMap->clear(); - regPtr0->getAll(keys1, valuesMap, NULLPTR, true); + regPtr0->getAll(keys1, valuesMap, nullptr, true); if (valuesMap->size() == keys1.size()) { char buf[2048]; for (HashMapOfCacheable::Iterator iter = valuesMap->begin(); iter != valuesMap->end(); iter++) { - CacheableKeyPtr key = dynCast<CacheableKeyPtr>(iter.first()); + auto key = std::dynamic_pointer_cast<CacheableKey>(iter.first()); CacheablePtr mVal = iter.second(); - if (mVal != NULLPTR) { - PdxTests::PdxTypes1Ptr val1 = dynCast<PdxTests::PdxTypes1Ptr>(mVal); + if (mVal != nullptr) { + auto val1 = std::dynamic_pointer_cast<PdxTests::PdxTypes1>(mVal); sprintf(buf, "value from map %d , expected value %d ", val1->getm_i1(), 34324); LOG(buf);