16
16
17
17
package io .confluent .connect .avro ;
18
18
19
+ import io .confluent .kafka .schemaregistry .avro .AvroSchema ;
19
20
import io .confluent .kafka .schemaregistry .client .rest .exceptions .RestClientException ;
20
21
import io .confluent .kafka .serializers .subject .RecordNameStrategy ;
21
22
36
37
37
38
import io .confluent .kafka .schemaregistry .client .MockSchemaRegistryClient ;
38
39
import io .confluent .kafka .schemaregistry .client .SchemaRegistryClient ;
39
- import io .confluent .kafka .serializers .AbstractKafkaAvroSerDe ;
40
- import io .confluent .kafka .serializers .AbstractKafkaAvroSerDeConfig ;
40
+ import io .confluent .kafka .serializers .AbstractKafkaSchemaSerDe ;
41
+ import io .confluent .kafka .serializers .AbstractKafkaSchemaSerDeConfig ;
41
42
import io .confluent .kafka .serializers .KafkaAvroSerializer ;
42
43
43
44
import static org .hamcrest .CoreMatchers .equalTo ;
@@ -56,7 +57,7 @@ public class AvroConverterTest {
56
57
private static final String TOPIC = "topic" ;
57
58
58
59
private static final Map <String , ?> SR_CONFIG = Collections .singletonMap (
59
- AbstractKafkaAvroSerDeConfig .SCHEMA_REGISTRY_URL_CONFIG , "localhost" );
60
+ AbstractKafkaSchemaSerDeConfig .SCHEMA_REGISTRY_URL_CONFIG , "localhost" );
60
61
61
62
private final SchemaRegistryClient schemaRegistry ;
62
63
private final AvroConverter converter ;
@@ -76,7 +77,7 @@ public void testConfigure() {
76
77
converter .configure (SR_CONFIG , true );
77
78
assertTrue (Whitebox .<Boolean >getInternalState (converter , "isKey" ));
78
79
assertNotNull (Whitebox .getInternalState (
79
- Whitebox .<AbstractKafkaAvroSerDe >getInternalState (converter , "serializer" ),
80
+ Whitebox .<AbstractKafkaSchemaSerDe >getInternalState (converter , "serializer" ),
80
81
"schemaRegistry" ));
81
82
}
82
83
@@ -85,7 +86,7 @@ public void testConfigureAlt() {
85
86
converter .configure (SR_CONFIG , false );
86
87
assertFalse (Whitebox .<Boolean >getInternalState (converter , "isKey" ));
87
88
assertNotNull (Whitebox .getInternalState (
88
- Whitebox .<AbstractKafkaAvroSerDe >getInternalState (converter , "serializer" ),
89
+ Whitebox .<AbstractKafkaSchemaSerDe >getInternalState (converter , "serializer" ),
89
90
"schemaRegistry" ));
90
91
}
91
92
@@ -197,14 +198,14 @@ private void testVersionExtracted(String subject, KafkaAvroSerializer serializer
197
198
.record ("Foo" ).fields ()
198
199
.requiredInt ("key" )
199
200
.endRecord ();
200
- schemaRegistry .register (subject , avroSchema1 );
201
+ schemaRegistry .register (subject , new AvroSchema ( avroSchema1 ) );
201
202
202
203
org .apache .avro .Schema avroSchema2 = org .apache .avro .SchemaBuilder
203
204
.record ("Foo" ).fields ()
204
205
.requiredInt ("key" )
205
206
.requiredString ("value" )
206
207
.endRecord ();
207
- schemaRegistry .register (subject , avroSchema2 );
208
+ schemaRegistry .register (subject , new AvroSchema ( avroSchema2 ) );
208
209
209
210
210
211
// Get serialized data
@@ -271,8 +272,8 @@ public void testSameSchemaMultipleTopicWithDeprecatedSubjectNameStrategyForValue
271
272
SchemaRegistryClient schemaRegistry = new MockSchemaRegistryClient ();
272
273
AvroConverter avroConverter = new AvroConverter (schemaRegistry );
273
274
Map <String , ?> converterConfig = ImmutableMap .of (
274
- AbstractKafkaAvroSerDeConfig .SCHEMA_REGISTRY_URL_CONFIG , "localhost" ,
275
- AbstractKafkaAvroSerDeConfig .VALUE_SUBJECT_NAME_STRATEGY , DeprecatedTestTopicNameStrategy .class .getName ());
275
+ AbstractKafkaSchemaSerDeConfig .SCHEMA_REGISTRY_URL_CONFIG , "localhost" ,
276
+ AbstractKafkaSchemaSerDeConfig .VALUE_SUBJECT_NAME_STRATEGY , DeprecatedTestTopicNameStrategy .class .getName ());
276
277
avroConverter .configure (converterConfig , false );
277
278
assertSameSchemaMultipleTopic (avroConverter , schemaRegistry , false );
278
279
}
@@ -282,8 +283,8 @@ public void testSameSchemaMultipleTopicWithDeprecatedSubjectNameStrategyForKey()
282
283
SchemaRegistryClient schemaRegistry = new MockSchemaRegistryClient ();
283
284
AvroConverter avroConverter = new AvroConverter (schemaRegistry );
284
285
Map <String , ?> converterConfig = ImmutableMap .of (
285
- AbstractKafkaAvroSerDeConfig .SCHEMA_REGISTRY_URL_CONFIG , "localhost" ,
286
- AbstractKafkaAvroSerDeConfig .KEY_SUBJECT_NAME_STRATEGY , DeprecatedTestTopicNameStrategy .class .getName ());
286
+ AbstractKafkaSchemaSerDeConfig .SCHEMA_REGISTRY_URL_CONFIG , "localhost" ,
287
+ AbstractKafkaSchemaSerDeConfig .KEY_SUBJECT_NAME_STRATEGY , DeprecatedTestTopicNameStrategy .class .getName ());
287
288
avroConverter .configure (converterConfig , true );
288
289
assertSameSchemaMultipleTopic (avroConverter , schemaRegistry , true );
289
290
}
@@ -300,7 +301,7 @@ public void testExplicitlyNamedNestedMapsWithNonStringKeys() {
300
301
final AvroConverter avroConverter = new AvroConverter (new MockSchemaRegistryClient ());
301
302
avroConverter .configure (
302
303
Collections .singletonMap (
303
- AbstractKafkaAvroSerDeConfig .SCHEMA_REGISTRY_URL_CONFIG , "localhost"
304
+ AbstractKafkaSchemaSerDeConfig .SCHEMA_REGISTRY_URL_CONFIG , "localhost"
304
305
),
305
306
false
306
307
);
@@ -330,9 +331,9 @@ private void assertSameSchemaMultipleTopic(AvroConverter converter, SchemaRegist
330
331
.requiredString ("value" )
331
332
.endRecord ();
332
333
String subjectSuffix = isKey ? "key" : "value" ;
333
- schemaRegistry .register ("topic1-" + subjectSuffix , avroSchema2_1 );
334
- schemaRegistry .register ("topic2-" + subjectSuffix , avroSchema1 );
335
- schemaRegistry .register ("topic2-" + subjectSuffix , avroSchema2_2 );
334
+ schemaRegistry .register ("topic1-" + subjectSuffix , new AvroSchema ( avroSchema2_1 ) );
335
+ schemaRegistry .register ("topic2-" + subjectSuffix , new AvroSchema ( avroSchema1 ) );
336
+ schemaRegistry .register ("topic2-" + subjectSuffix , new AvroSchema ( avroSchema2_2 ) );
336
337
337
338
org .apache .avro .generic .GenericRecord avroRecord1
338
339
= new org .apache .avro .generic .GenericRecordBuilder (avroSchema2_1 ).set ("key" , 15 ).set
0 commit comments