88import com .yahoo .bullet .querying .partitioning .MockPartitioner ;
99import com .yahoo .bullet .record .BulletRecord ;
1010import com .yahoo .bullet .record .BulletRecordProvider ;
11+ import com .yahoo .bullet .record .avro .TypedAvroBulletRecordProvider ;
12+ import com .yahoo .bullet .record .simple .TypedSimpleBulletRecordProvider ;
1113import com .yahoo .bullet .result .Meta ;
1214import com .yahoo .bullet .result .Meta .Concept ;
1315import com .yahoo .bullet .typesystem .Type ;
@@ -461,11 +463,13 @@ public void testGetBulletRecordProvider() {
461463 BulletConfig config = new BulletConfig ();
462464 BulletRecordProvider providerA = config .getBulletRecordProvider ();
463465 BulletRecordProvider providerB = config .getBulletRecordProvider ();
464- Assert .assertEquals (providerA , providerB );
466+
467+ // Creates a new provider each time
468+ Assert .assertNotEquals (providerA , providerB );
465469
466470 // Ensure the provider generates new records each time
467471 BulletRecord recordA = providerA .getInstance ();
468- BulletRecord recordB = providerB .getInstance ();
472+ BulletRecord recordB = providerA .getInstance ();
469473
470474 Assert .assertNotNull (recordA );
471475 Assert .assertNotNull (recordB );
@@ -475,6 +479,31 @@ public void testGetBulletRecordProvider() {
475479 Assert .assertTrue (recordA .typedGet ("someField" ).isNull ());
476480 }
477481
482+ @ Test
483+ public void testGetCachedBulletRecordProvider () {
484+ BulletConfig config = new BulletConfig ();
485+ BulletRecordProvider providerA = config .getCachedBulletRecordProvider ();
486+ BulletRecordProvider providerB = config .getCachedBulletRecordProvider ();
487+
488+ // Uses the same provider
489+ Assert .assertSame (providerA , providerB );
490+ }
491+
492+ @ Test
493+ public void testSettingDifferentBulletRecordProvider () {
494+ BulletConfig config = new BulletConfig ();
495+
496+ // Default record provider is TypedAvroBulletRecordProvider
497+ Assert .assertTrue (config .getBulletRecordProvider () instanceof TypedAvroBulletRecordProvider );
498+
499+ config .set (BulletConfig .RECORD_PROVIDER_CLASS_NAME , TypedSimpleBulletRecordProvider .class .getName ());
500+
501+ // Cached record provider doesn't change with new setting
502+ Assert .assertTrue (config .getCachedBulletRecordProvider () instanceof TypedAvroBulletRecordProvider );
503+
504+ Assert .assertTrue (config .getBulletRecordProvider () instanceof TypedSimpleBulletRecordProvider );
505+ }
506+
478507 @ Test (expectedExceptions = IllegalStateException .class )
479508 public void testEqualityPartitioningWithNoFieldsValidation () {
480509 BulletConfig config = new BulletConfig ();
0 commit comments