You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@geode.apache.org by GitBox <gi...@apache.org> on 2022/02/16 17:31:32 UTC

[GitHub] [geode-native] pdxcodemonkey commented on a change in pull request #806: GEODE-9268: Fix PdxInstance handling after cluster restart

pdxcodemonkey commented on a change in pull request #806:
URL: https://github.com/apache/geode-native/pull/806#discussion_r808276065



##########
File path: cppcache/integration/test/PdxInstanceTest.cpp
##########
@@ -273,32 +270,51 @@ TEST(PdxInstanceTest, testPdxInstance) {
 
   EXPECT_EQ(-960665662, pdxTypeInstance->hashcode())
       << "Pdxhashcode hashcode not matched with java pdx hash code.";
+}
 
-  // TODO split into separate test for nested pdx object test.
-  ParentPdx pdxParentOriginal(10);
-  auto pdxParentInstanceFactory =
-      cache.createPdxInstanceFactory("testobject.ParentPdx");
-  clonePdxInstance(pdxParentOriginal, pdxParentInstanceFactory);
-  auto pdxParentInstance = pdxParentInstanceFactory.create();
-  EXPECT_EQ("testobject.ParentPdx", pdxParentInstance->getClassName())
-      << "pdxTypeInstance.getClassName should return testobject.ParentPdx.";
+TEST(PdxInstanceTest, testNestedPdxInstance) {
+  Cluster cluster{LocatorCount{1}, ServerCount{1}};
+
+  cluster.start();
+
+  cluster.getGfsh()
+      .create()
+      .region()
+      .withName("region")
+      .withType("REPLICATE")
+      .execute();
+
+  auto cache = cluster.createCache();
+  auto region = setupRegion(cache);
+  auto&& typeRegistry = cache.getTypeRegistry();
+  auto&& cachePerfStats = std::dynamic_pointer_cast<LocalRegion>(region)
+                              ->getCacheImpl()
+                              ->getCachePerfStats();
+
+  typeRegistry.registerPdxType(ChildPdx::createDeserializable);
+  typeRegistry.registerPdxType(ParentPdx::createDeserializable);
+
+  ParentPdx original{10};
+  auto factory = cache.createPdxInstanceFactory(original.getClassName());
+  clonePdxInstance(original, factory);
+  auto pdxInstance = factory.create();
 
   auto keyport = CacheableKey::create("pdxParentOriginal");
-  region->put(keyport, pdxParentInstance);
-  auto objectFromPdxParentInstanceGet =
+  region->put(keyport, pdxInstance);
+  auto object =
       std::dynamic_pointer_cast<PdxSerializable>(region->get(keyport));
+  EXPECT_TRUE(object);
 
-  EXPECT_EQ(1, cachePerfStats.getPdxInstanceDeserializations())
+  EXPECT_EQ(0, cachePerfStats.getPdxInstanceDeserializations())
       << "pdxInstanceDeserialization should be equal to 1.";

Review comment:
       The statements on lines 237 and 258 still don't agree with the text, pls fix to avoid confusion.




-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@geode.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org