@@ -12,7 +12,11 @@ import stringify from 'json-stringify-deterministic';
1212import { v4 } from 'uuid' ;
1313
1414let schemaRegistryClient : SchemaRegistryClient ;
15- let producer : any ;
15+ let serializerConfig : AvroSerializerConfig ;
16+ let serializer : AvroSerializer ;
17+ let deserializer : AvroDeserializer ;
18+ let producer : KafkaJS . Producer ;
19+ let consumer : KafkaJS . Consumer ;
1620
1721const kafkaBrokerList = 'localhost:9092' ;
1822const kafka = new KafkaJS . Kafka ( {
@@ -48,11 +52,6 @@ const schemaInfo: SchemaInfo = {
4852 metadata : metadata
4953} ;
5054
51- let serializerConfig : AvroSerializerConfig ;
52- let serializer : AvroSerializer ;
53- let deserializer : AvroDeserializer ;
54- let consumer : KafkaJS . Consumer ;
55-
5655describe ( 'Schema Registry Avro Integration Test' , ( ) => {
5756
5857 beforeEach ( async ( ) => {
@@ -78,15 +77,14 @@ describe('Schema Registry Avro Integration Test', () => {
7877
7978 afterEach ( async ( ) => {
8079 await producer . disconnect ( ) ;
81- producer = null ;
8280 } ) ;
8381
8482 it ( "Should serialize and deserialize Avro" , async ( ) => {
85- const testTopic = 'test-topic-' + v4 ( ) ;
83+ const testTopic = v4 ( ) ;
8684
87- await schemaRegistryClient . register ( testTopic , schemaInfo ) ;
85+ await schemaRegistryClient . register ( testTopic + "-value" , schemaInfo ) ;
8886
89- serializerConfig = { autoRegisterSchemas : true } ;
87+ serializerConfig = { useLatestVersion : true } ;
9088 serializer = new AvroSerializer ( schemaRegistryClient , SerdeType . VALUE , serializerConfig ) ;
9189 deserializer = new AvroDeserializer ( schemaRegistryClient , SerdeType . VALUE , { } ) ;
9290
@@ -123,28 +121,8 @@ describe('Schema Registry Avro Integration Test', () => {
123121 await consumer . disconnect ( ) ;
124122 } , 30000 ) ;
125123
126- it ( " Should serialize with UseLatestVersion enabled" , async ( ) => {
124+ it ( ' Should fail to serialize with useLatestVersion enabled and autoRegisterSchemas disabled' , async ( ) => {
127125 const testTopic = v4 ( ) ;
128- await schemaRegistryClient . register ( testTopic , schemaInfo ) ;
129-
130- serializerConfig = { autoRegisterSchemas : true , useLatestVersion : true } ;
131- serializer = new AvroSerializer ( schemaRegistryClient , SerdeType . VALUE , serializerConfig ) ;
132-
133- const outgoingMessage = {
134- key : 'key' ,
135- value : await serializer . serialize ( testTopic , messageValue )
136- } ;
137-
138- await producer . send ( {
139- topic : testTopic ,
140- messages : [ outgoingMessage ]
141- } ) ;
142-
143- } , 30000 ) ;
144-
145- it ( 'Should fail to serialize with UseLatestVersion enabled and autoRegisterSchemas disabled' , async ( ) => {
146- const testTopic = v4 ( ) ;
147- await schemaRegistryClient . register ( testTopic , schemaInfo ) ;
148126
149127 serializerConfig = { autoRegisterSchemas : false , useLatestVersion : true } ;
150128 serializer = new AvroSerializer ( schemaRegistryClient , SerdeType . VALUE , serializerConfig ) ;
@@ -154,12 +132,11 @@ describe('Schema Registry Avro Integration Test', () => {
154132 await expect ( serializer . serialize ( testTopic , messageValue ) ) . rejects . toThrowError ( ) ;
155133 } ) ;
156134
157- it ( 'Should serialize with schemas registered, UseLatestVersion enabled and autoRegisterSchemas disabled' , async ( ) => {
135+ it ( 'Should serialize with autoRegisterSchemas enabled and useLatestVersion disabled' , async ( ) => {
158136 const testTopic = v4 ( ) ;
159- await schemaRegistryClient . register ( testTopic , schemaInfo ) ;
160- await schemaRegistryClient . register ( testTopic + '-value' , schemaInfo ) ;
137+ await schemaRegistryClient . register ( testTopic + ' -value' , schemaInfo ) ;
161138
162- serializerConfig = { autoRegisterSchemas : false , useLatestVersion : true } ;
139+ serializerConfig = { autoRegisterSchemas : true , useLatestVersion : false } ;
163140 serializer = new AvroSerializer ( schemaRegistryClient , SerdeType . VALUE , serializerConfig ) ;
164141
165142 const messageValue = { "name" : "Bob Jones" , "age" : 25 } ;
@@ -257,7 +234,7 @@ describe('Schema Registry Avro Integration Test - Primitives', () => {
257234 }
258235 } ) ;
259236 await producer . connect ( ) ;
260- serializerConfig = { autoRegisterSchemas : true } ;
237+ serializerConfig = { useLatestVersion : true } ;
261238
262239 serializer = new AvroSerializer ( schemaRegistryClient , SerdeType . VALUE , serializerConfig ) ;
263240 deserializer = new AvroDeserializer ( schemaRegistryClient , SerdeType . VALUE , { } ) ;
@@ -272,7 +249,6 @@ describe('Schema Registry Avro Integration Test - Primitives', () => {
272249
273250 afterEach ( async ( ) => {
274251 await producer . disconnect ( ) ;
275- producer = null ;
276252 } ) ;
277253
278254 it ( 'Should serialize and deserialize string' , async ( ) => {
@@ -287,7 +263,7 @@ describe('Schema Registry Avro Integration Test - Primitives', () => {
287263 metadata : metadata
288264 } ;
289265
290- await schemaRegistryClient . register ( stringTopic , stringSchemaInfo ) ;
266+ await schemaRegistryClient . register ( stringTopic + "-value" , stringSchemaInfo ) ;
291267
292268 const stringMessageValue = "Hello, World!" ;
293269 const outgoingStringMessage = {
@@ -335,7 +311,7 @@ describe('Schema Registry Avro Integration Test - Primitives', () => {
335311 metadata : metadata
336312 } ;
337313
338- await schemaRegistryClient . register ( topic , stringSchemaInfo ) ;
314+ await schemaRegistryClient . register ( topic + "-value" , stringSchemaInfo ) ;
339315
340316 const messageValue = Buffer . from ( "Hello, World!" ) ;
341317 const outgoingMessage = {
@@ -383,7 +359,7 @@ describe('Schema Registry Avro Integration Test - Primitives', () => {
383359 metadata : metadata
384360 } ;
385361
386- await schemaRegistryClient . register ( topic , stringSchemaInfo ) ;
362+ await schemaRegistryClient . register ( topic + "-value" , stringSchemaInfo ) ;
387363
388364 const messageValue = 25 ;
389365 const outgoingMessage = {
@@ -431,7 +407,7 @@ describe('Schema Registry Avro Integration Test - Primitives', () => {
431407 metadata : metadata
432408 } ;
433409
434- await schemaRegistryClient . register ( topic , stringSchemaInfo ) ;
410+ await schemaRegistryClient . register ( topic + "-value" , stringSchemaInfo ) ;
435411
436412 const messageValue = 25 ;
437413 const outgoingMessage = {
@@ -479,7 +455,7 @@ describe('Schema Registry Avro Integration Test - Primitives', () => {
479455 metadata : metadata
480456 } ;
481457
482- await schemaRegistryClient . register ( topic , stringSchemaInfo ) ;
458+ await schemaRegistryClient . register ( topic + "-value" , stringSchemaInfo ) ;
483459
484460 const messageValue = true ;
485461 const outgoingMessage = {
@@ -527,7 +503,7 @@ describe('Schema Registry Avro Integration Test - Primitives', () => {
527503 metadata : metadata
528504 } ;
529505
530- await schemaRegistryClient . register ( topic , stringSchemaInfo ) ;
506+ await schemaRegistryClient . register ( topic + "-value" , stringSchemaInfo ) ;
531507
532508 const messageValue = 1.354 ;
533509 const outgoingMessage = {
@@ -575,7 +551,7 @@ describe('Schema Registry Avro Integration Test - Primitives', () => {
575551 metadata : metadata
576552 } ;
577553
578- await schemaRegistryClient . register ( topic , stringSchemaInfo ) ;
554+ await schemaRegistryClient . register ( topic + "-value" , stringSchemaInfo ) ;
579555
580556 const messageValue = 1.354 ;
581557 const outgoingMessage = {
0 commit comments