imbajin commented on code in PR #3141:
URL: https://github.com/apache/hugegraph/pull/3141#discussion_r3733948494
##########
hugegraph-server/hugegraph-hstore/src/test/java/org/apache/hugegraph/backend/store/hstore/HstoreSessionsImplTest.java:
##########
@@ -36,4 +39,30 @@ public void testProductionClassDoesNotReferenceTestAssert()
throws IOException {
"org/apache/hugegraph/testutil/Assert"));
}
}
+
+ @Test
+ public void testClearInitializedGraphStateRepeatedly() throws Exception {
+ Field initializedGraphField =
HstoreSessionsImpl.class.getDeclaredField(
+ "infoInitializedGraph");
+ initializedGraphField.setAccessible(true);
+ @SuppressWarnings("unchecked")
+ Set<String> initializedGraphs =
+ (Set<String>) initializedGraphField.get(null);
+
+ Method clearInitializedGraph =
+ HstoreSessionsImpl.class.getDeclaredMethod(
+ "clearInitializedGraph", String.class);
+ clearInitializedGraph.setAccessible(true);
+
+ String graphName = "hugegraph/hstore-clear-test";
+ try {
+ for (int i = 0; i < 50; i++) {
+ Assert.assertTrue(initializedGraphs.add(graphName));
+ clearInitializedGraph.invoke(null, graphName);
Review Comment:
⚠️ This test invokes private `clearInitializedGraph()` via reflection
instead of exercising `HstoreSessionsImpl.clear()`. It would still pass if the
`finally` call at `HstoreSessionsImpl.java:188` were removed or misplaced, and
it does not verify the reported clear/recreate lifecycle. Please cover the
public clear path (ideally the repeated clear/recreate sequence) and assert
that a subsequent open re-registers the graph, or use controllable fakes to
verify that behavior.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]