@@ -397,16 +397,15 @@ public void testClearV2SchemaCacheByGraphName() {
397397 String graphName = "DEFAULT-unit-test-v2" ;
398398 String otherGraphName = "DEFAULT-other-v2" ;
399399
400- Cache <Id , Object > idCache = CacheManager .instance ()
401- .cache ("schema-id-" +
402- graphName , 10L );
403- Cache <Id , Object > nameCache = CacheManager .instance ()
404- .cache ("schema-name-" +
405- graphName , 10L );
406- Cache <Id , Object > otherIdCache = CacheManager .instance ()
407- .cache ("schema-id-" +
408- otherGraphName ,
409- 10L );
400+ Cache <Id , Object > idCache = v2IdCache (graphName );
401+ Cache <Id , Object > nameCache = v2NameCache (graphName );
402+ Cache <Id , Object > otherIdCache = v2IdCache (otherGraphName );
403+ Cache <Id , Object > v1IdCache = CacheManager .instance ()
404+ .cache ("schema-id-" +
405+ graphName , 10L );
406+ Cache <Id , Object > v1NameCache = CacheManager .instance ()
407+ .cache ("schema-name-" +
408+ graphName , 10L );
410409 Object arrayCaches = idCache .attachment (newV2SchemaCaches (10 ));
411410 Id arrayCacheId = IdGenerator .of (1 );
412411 SchemaElement arrayCacheSchema =
@@ -420,10 +419,16 @@ public void testClearV2SchemaCacheByGraphName() {
420419 idCache .update (IdGenerator .of (1 ), "fake-pk-by-id" );
421420 nameCache .update (IdGenerator .of ("fake-pk" ), "fake-pk-by-name" );
422421 otherIdCache .update (IdGenerator .of (2 ), "other-pk-by-id" );
422+ v1IdCache .update (IdGenerator .of (3 ), "v1-pk-by-id" );
423+ v1NameCache .update (IdGenerator .of ("v1-pk" ), "v1-pk-by-name" );
423424
425+ Assert .assertNotSame (v1IdCache , idCache );
426+ Assert .assertNotSame (v1NameCache , nameCache );
424427 Assert .assertEquals (1L , idCache .size ());
425428 Assert .assertEquals (1L , nameCache .size ());
426429 Assert .assertEquals (1L , otherIdCache .size ());
430+ Assert .assertEquals (1L , v1IdCache .size ());
431+ Assert .assertEquals (1L , v1NameCache .size ());
427432 Assert .assertSame (arrayCacheSchema ,
428433 getV2SchemaCache (arrayCaches ,
429434 HugeType .PROPERTY_KEY ,
@@ -436,6 +441,8 @@ public void testClearV2SchemaCacheByGraphName() {
436441 Assert .assertEquals (0L , idCache .size ());
437442 Assert .assertEquals (0L , nameCache .size ());
438443 Assert .assertEquals (1L , otherIdCache .size ());
444+ Assert .assertEquals (1L , v1IdCache .size ());
445+ Assert .assertEquals (1L , v1NameCache .size ());
439446 Assert .assertNull (getV2SchemaCache (arrayCaches ,
440447 HugeType .PROPERTY_KEY ,
441448 arrayCacheId ));
@@ -444,9 +451,28 @@ public void testClearV2SchemaCacheByGraphName() {
444451 idCache .clear ();
445452 nameCache .clear ();
446453 otherIdCache .clear ();
454+ v1IdCache .clear ();
455+ v1NameCache .clear ();
447456 }
448457 }
449458
459+ private static Cache <Id , Object > v2IdCache (String graphName ) {
460+ return v2Cache ("ID_CACHE_PREFIX" , graphName );
461+ }
462+
463+ private static Cache <Id , Object > v2NameCache (String graphName ) {
464+ return v2Cache ("NAME_CACHE_PREFIX" , graphName );
465+ }
466+
467+ private static Cache <Id , Object > v2Cache (String prefixField ,
468+ String graphName ) {
469+ // Keep test fixtures aligned with the private cache namespace used by
470+ // CachedSchemaTransactionV2 without duplicating production literals.
471+ String prefix = Whitebox .getInternalState (
472+ CachedSchemaTransactionV2 .class , prefixField );
473+ return CacheManager .instance ().cache (prefix + "-" + graphName , 10L );
474+ }
475+
450476 private static Object newV2SchemaCaches (int size ) {
451477 for (Class <?> clazz :
452478 CachedSchemaTransactionV2 .class .getDeclaredClasses ()) {
@@ -534,10 +560,8 @@ public void testClearSchemaCacheClearsArrayAttachmentMaps()
534560 // IntObjectMap (pks/vls/els/ils) inside the array attachment so
535561 // stale entries are not served after a meta event.
536562 String graphName = "DEFAULT-unit-test-v2-array" ;
537- Cache <Id , Object > idCache =
538- CacheManager .instance ().cache ("schema-id-" + graphName , 10L );
539- Cache <Id , Object > nameCache =
540- CacheManager .instance ().cache ("schema-name-" + graphName , 10L );
563+ Cache <Id , Object > idCache = v2IdCache (graphName );
564+ Cache <Id , Object > nameCache = v2NameCache (graphName );
541565 // Size must comfortably exceed the largest id below: IntObjectMap
542566 // grows by doubling and refuses to write past currentSize even after
543567 // a single expansion, so a small capacity rejects mid-range keys.
@@ -598,11 +622,8 @@ public void testClearSchemaCacheClearsArrayAttachmentMaps()
598622 public void testHandleSchemaCacheClearEventSkipsLocalSource ()
599623 throws Exception {
600624 String graphName = "DEFAULT-meta-local-source-v2" ;
601- Cache <Id , Object > idCache =
602- CacheManager .instance ().cache ("schema-id-" + graphName , 10L );
603- Cache <Id , Object > nameCache =
604- CacheManager .instance ()
605- .cache ("schema-name-" + graphName , 10L );
625+ Cache <Id , Object > idCache = v2IdCache (graphName );
626+ Cache <Id , Object > nameCache = v2NameCache (graphName );
606627
607628 MetaDriver mockDriver = Mockito .mock (MetaDriver .class );
608629 Object localResponse = new Object ();
@@ -658,13 +679,9 @@ public void testHandleSchemaCacheClearEventClearsTargetGraphOnly()
658679 String targetGraph = "DEFAULT-meta-target-v2" ;
659680 String otherGraph = "DEFAULT-meta-other-v2" ;
660681
661- Cache <Id , Object > targetIdCache =
662- CacheManager .instance ().cache ("schema-id-" + targetGraph , 10L );
663- Cache <Id , Object > targetNameCache =
664- CacheManager .instance ()
665- .cache ("schema-name-" + targetGraph , 10L );
666- Cache <Id , Object > otherIdCache =
667- CacheManager .instance ().cache ("schema-id-" + otherGraph , 10L );
682+ Cache <Id , Object > targetIdCache = v2IdCache (targetGraph );
683+ Cache <Id , Object > targetNameCache = v2NameCache (targetGraph );
684+ Cache <Id , Object > otherIdCache = v2IdCache (otherGraph );
668685
669686 MetaDriver mockDriver = Mockito .mock (MetaDriver .class );
670687 Object response = new Object ();
@@ -703,8 +720,7 @@ public void testHandleSchemaCacheClearEventNullGraphsIsNoop()
703720 // A response that yields no graph names (extractor returns null) must
704721 // be a strict noop: caches stay populated.
705722 String graphName = "DEFAULT-meta-noop-v2" ;
706- Cache <Id , Object > idCache =
707- CacheManager .instance ().cache ("schema-id-" + graphName , 10L );
723+ Cache <Id , Object > idCache = v2IdCache (graphName );
708724
709725 MetaDriver mockDriver = Mockito .mock (MetaDriver .class );
710726 Object response = new Object ();
@@ -735,10 +751,8 @@ public void testHandleSchemaCacheClearEventClearsMultipleGraphs()
735751 // them must have its V2 caches cleared.
736752 String graphA = "DEFAULT-meta-multi-a" ;
737753 String graphB = "DEFAULT-meta-multi-b" ;
738- Cache <Id , Object > idA =
739- CacheManager .instance ().cache ("schema-id-" + graphA , 10L );
740- Cache <Id , Object > idB =
741- CacheManager .instance ().cache ("schema-id-" + graphB , 10L );
754+ Cache <Id , Object > idA = v2IdCache (graphA );
755+ Cache <Id , Object > idB = v2IdCache (graphB );
742756
743757 MetaDriver mockDriver = Mockito .mock (MetaDriver .class );
744758 Object response = new Object ();
@@ -811,11 +825,8 @@ public void testListenSchemaCacheClearEndToEnd() throws Exception {
811825 // MetaDriver, then invoke it as the watch would and assert the V2
812826 // caches for the named graph are cleared.
813827 String graphName = "DEFAULT-end-to-end-v2" ;
814- Cache <Id , Object > idCache =
815- CacheManager .instance ().cache ("schema-id-" + graphName , 10L );
816- Cache <Id , Object > nameCache =
817- CacheManager .instance ()
818- .cache ("schema-name-" + graphName , 10L );
828+ Cache <Id , Object > idCache = v2IdCache (graphName );
829+ Cache <Id , Object > nameCache = v2NameCache (graphName );
819830
820831 MetaDriver mockDriver = Mockito .mock (MetaDriver .class );
821832 Object response = new Object ();
0 commit comments