55
55
*/
56
56
class PulsarPropertiesTests {
57
57
58
- private PulsarProperties bindPropeties (Map <String , String > map ) {
58
+ private PulsarProperties bindProperties (Map <String , String > map ) {
59
59
return new Binder (new MapConfigurationPropertySource (map )).bind ("spring.pulsar" , PulsarProperties .class ).get ();
60
60
}
61
61
@@ -69,7 +69,7 @@ void bind() {
69
69
map .put ("spring.pulsar.client.operation-timeout" , "1s" );
70
70
map .put ("spring.pulsar.client.lookup-timeout" , "2s" );
71
71
map .put ("spring.pulsar.client.connection-timeout" , "12s" );
72
- PulsarProperties .Client properties = bindPropeties (map ).getClient ();
72
+ PulsarProperties .Client properties = bindProperties (map ).getClient ();
73
73
assertThat (properties .getServiceUrl ()).isEqualTo ("my-service-url" );
74
74
assertThat (properties .getOperationTimeout ()).isEqualTo (Duration .ofMillis (1000 ));
75
75
assertThat (properties .getLookupTimeout ()).isEqualTo (Duration .ofMillis (2000 ));
@@ -81,7 +81,7 @@ void bindAuthentication() {
81
81
Map <String , String > map = new HashMap <>();
82
82
map .put ("spring.pulsar.client.authentication.plugin-class-name" , "com.example.MyAuth" );
83
83
map .put ("spring.pulsar.client.authentication.param.token" , "1234" );
84
- PulsarProperties .Client properties = bindPropeties (map ).getClient ();
84
+ PulsarProperties .Client properties = bindProperties (map ).getClient ();
85
85
assertThat (properties .getAuthentication ().getPluginClassName ()).isEqualTo ("com.example.MyAuth" );
86
86
assertThat (properties .getAuthentication ().getParam ()).containsEntry ("token" , "1234" );
87
87
}
@@ -101,7 +101,7 @@ void bindFailover() {
101
101
map .put ("spring.pulsar.client.failover.backup-clusters[1].authentication.plugin-class-name" ,
102
102
"com.example.MyAuth2" );
103
103
map .put ("spring.pulsar.client.failover.backup-clusters[1].authentication.param.token" , "5678" );
104
- PulsarProperties .Client properties = bindPropeties (map ).getClient ();
104
+ PulsarProperties .Client properties = bindProperties (map ).getClient ();
105
105
Failover failoverProperties = properties .getFailover ();
106
106
List <BackupCluster > backupClusters = properties .getFailover ().getBackupClusters ();
107
107
assertThat (properties .getServiceUrl ()).isEqualTo ("my-service-url" );
@@ -132,7 +132,7 @@ void bind() {
132
132
map .put ("spring.pulsar.admin.connection-timeout" , "12s" );
133
133
map .put ("spring.pulsar.admin.read-timeout" , "13s" );
134
134
map .put ("spring.pulsar.admin.request-timeout" , "14s" );
135
- PulsarProperties .Admin properties = bindPropeties (map ).getAdmin ();
135
+ PulsarProperties .Admin properties = bindProperties (map ).getAdmin ();
136
136
assertThat (properties .getServiceUrl ()).isEqualTo ("my-service-url" );
137
137
assertThat (properties .getConnectionTimeout ()).isEqualTo (Duration .ofSeconds (12 ));
138
138
assertThat (properties .getReadTimeout ()).isEqualTo (Duration .ofSeconds (13 ));
@@ -144,7 +144,7 @@ void bindAuthentication() {
144
144
Map <String , String > map = new HashMap <>();
145
145
map .put ("spring.pulsar.admin.authentication.plugin-class-name" , this .authPluginClassName );
146
146
map .put ("spring.pulsar.admin.authentication.param.token" , this .authToken );
147
- PulsarProperties .Admin properties = bindPropeties (map ).getAdmin ();
147
+ PulsarProperties .Admin properties = bindProperties (map ).getAdmin ();
148
148
assertThat (properties .getAuthentication ().getPluginClassName ()).isEqualTo (this .authPluginClassName );
149
149
assertThat (properties .getAuthentication ().getParam ()).containsEntry ("token" , this .authToken );
150
150
}
@@ -166,7 +166,7 @@ void bindWhenTypeMappingsWithTopicsOnly() {
166
166
map .put ("spring.pulsar.defaults.type-mappings[0].topic-name" , "foo-topic" );
167
167
map .put ("spring.pulsar.defaults.type-mappings[1].message-type" , String .class .getName ());
168
168
map .put ("spring.pulsar.defaults.type-mappings[1].topic-name" , "string-topic" );
169
- PulsarProperties .Defaults properties = bindPropeties (map ).getDefaults ();
169
+ PulsarProperties .Defaults properties = bindProperties (map ).getDefaults ();
170
170
TypeMapping expectedTopic1 = new TypeMapping (TestMessage .class , "foo-topic" , null );
171
171
TypeMapping expectedTopic2 = new TypeMapping (String .class , "string-topic" , null );
172
172
assertThat (properties .getTypeMappings ()).containsExactly (expectedTopic1 , expectedTopic2 );
@@ -177,7 +177,7 @@ void bindWhenTypeMappingsWithSchemaOnly() {
177
177
Map <String , String > map = new HashMap <>();
178
178
map .put ("spring.pulsar.defaults.type-mappings[0].message-type" , TestMessage .class .getName ());
179
179
map .put ("spring.pulsar.defaults.type-mappings[0].schema-info.schema-type" , "JSON" );
180
- PulsarProperties .Defaults properties = bindPropeties (map ).getDefaults ();
180
+ PulsarProperties .Defaults properties = bindProperties (map ).getDefaults ();
181
181
TypeMapping expected = new TypeMapping (TestMessage .class , null , new SchemaInfo (SchemaType .JSON , null ));
182
182
assertThat (properties .getTypeMappings ()).containsExactly (expected );
183
183
}
@@ -188,7 +188,7 @@ void bindWhenTypeMappingsWithTopicAndSchema() {
188
188
map .put ("spring.pulsar.defaults.type-mappings[0].message-type" , TestMessage .class .getName ());
189
189
map .put ("spring.pulsar.defaults.type-mappings[0].topic-name" , "foo-topic" );
190
190
map .put ("spring.pulsar.defaults.type-mappings[0].schema-info.schema-type" , "JSON" );
191
- PulsarProperties .Defaults properties = bindPropeties (map ).getDefaults ();
191
+ PulsarProperties .Defaults properties = bindProperties (map ).getDefaults ();
192
192
TypeMapping expected = new TypeMapping (TestMessage .class , "foo-topic" ,
193
193
new SchemaInfo (SchemaType .JSON , null ));
194
194
assertThat (properties .getTypeMappings ()).containsExactly (expected );
@@ -200,7 +200,7 @@ void bindWhenTypeMappingsWithKeyValueSchema() {
200
200
map .put ("spring.pulsar.defaults.type-mappings[0].message-type" , TestMessage .class .getName ());
201
201
map .put ("spring.pulsar.defaults.type-mappings[0].schema-info.schema-type" , "KEY_VALUE" );
202
202
map .put ("spring.pulsar.defaults.type-mappings[0].schema-info.message-key-type" , String .class .getName ());
203
- PulsarProperties .Defaults properties = bindPropeties (map ).getDefaults ();
203
+ PulsarProperties .Defaults properties = bindProperties (map ).getDefaults ();
204
204
TypeMapping expected = new TypeMapping (TestMessage .class , null ,
205
205
new SchemaInfo (SchemaType .KEY_VALUE , String .class ));
206
206
assertThat (properties .getTypeMappings ()).containsExactly (expected );
@@ -211,7 +211,7 @@ void bindWhenNoSchemaThrowsException() {
211
211
Map <String , String > map = new HashMap <>();
212
212
map .put ("spring.pulsar.defaults.type-mappings[0].message-type" , TestMessage .class .getName ());
213
213
map .put ("spring.pulsar.defaults.type-mappings[0].schema-info.message-key-type" , String .class .getName ());
214
- assertThatExceptionOfType (BindException .class ).isThrownBy (() -> bindPropeties (map ))
214
+ assertThatExceptionOfType (BindException .class ).isThrownBy (() -> bindProperties (map ))
215
215
.havingRootCause ()
216
216
.withMessageContaining ("schemaType must not be null" );
217
217
}
@@ -221,7 +221,7 @@ void bindWhenSchemaTypeNoneThrowsException() {
221
221
Map <String , String > map = new HashMap <>();
222
222
map .put ("spring.pulsar.defaults.type-mappings[0].message-type" , TestMessage .class .getName ());
223
223
map .put ("spring.pulsar.defaults.type-mappings[0].schema-info.schema-type" , "NONE" );
224
- assertThatExceptionOfType (BindException .class ).isThrownBy (() -> bindPropeties (map ))
224
+ assertThatExceptionOfType (BindException .class ).isThrownBy (() -> bindProperties (map ))
225
225
.havingRootCause ()
226
226
.withMessageContaining ("schemaType 'NONE' not supported" );
227
227
}
@@ -232,7 +232,7 @@ void bindWhenMessageKeyTypeSetOnNonKeyValueSchemaThrowsException() {
232
232
map .put ("spring.pulsar.defaults.type-mappings[0].message-type" , TestMessage .class .getName ());
233
233
map .put ("spring.pulsar.defaults.type-mappings[0].schema-info.schema-type" , "JSON" );
234
234
map .put ("spring.pulsar.defaults.type-mappings[0].schema-info.message-key-type" , String .class .getName ());
235
- assertThatExceptionOfType (BindException .class ).isThrownBy (() -> bindPropeties (map ))
235
+ assertThatExceptionOfType (BindException .class ).isThrownBy (() -> bindProperties (map ))
236
236
.havingRootCause ()
237
237
.withMessageContaining ("messageKeyType can only be set when schemaType is KEY_VALUE" );
238
238
}
@@ -259,7 +259,7 @@ void bind() {
259
259
props .put ("spring.pulsar.function.fail-fast" , "false" );
260
260
props .put ("spring.pulsar.function.propagate-failures" , "false" );
261
261
props .put ("spring.pulsar.function.propagate-stop-failures" , "true" );
262
- PulsarProperties .Function properties = bindPropeties (props ).getFunction ();
262
+ PulsarProperties .Function properties = bindProperties (props ).getFunction ();
263
263
assertThat (properties .isFailFast ()).isFalse ();
264
264
assertThat (properties .isPropagateFailures ()).isFalse ();
265
265
assertThat (properties .isPropagateStopFailures ()).isTrue ();
@@ -285,7 +285,7 @@ void bind() {
285
285
map .put ("spring.pulsar.producer.cache.expire-after-access" , "2s" );
286
286
map .put ("spring.pulsar.producer.cache.maximum-size" , "3" );
287
287
map .put ("spring.pulsar.producer.cache.initial-capacity" , "5" );
288
- PulsarProperties .Producer properties = bindPropeties (map ).getProducer ();
288
+ PulsarProperties .Producer properties = bindProperties (map ).getProducer ();
289
289
assertThat (properties .getName ()).isEqualTo ("my-producer" );
290
290
assertThat (properties .getTopicName ()).isEqualTo ("my-topic" );
291
291
assertThat (properties .getSendTimeout ()).isEqualTo (Duration .ofSeconds (2 ));
@@ -323,7 +323,7 @@ void bind() {
323
323
map .put ("spring.pulsar.consumer.dead-letter-policy.dead-letter-topic" , "my-dlt-topic" );
324
324
map .put ("spring.pulsar.consumer.dead-letter-policy.initial-subscription-name" , "my-initial-subscription" );
325
325
map .put ("spring.pulsar.consumer.retry-enable" , "true" );
326
- PulsarProperties .Consumer properties = bindPropeties (map ).getConsumer ();
326
+ PulsarProperties .Consumer properties = bindProperties (map ).getConsumer ();
327
327
assertThat (properties .getName ()).isEqualTo ("my-consumer" );
328
328
assertThat (properties .getSubscription ()).satisfies ((subscription ) -> {
329
329
assertThat (subscription .getName ()).isEqualTo ("my-subscription" );
@@ -355,7 +355,7 @@ void bind() {
355
355
Map <String , String > map = new HashMap <>();
356
356
map .put ("spring.pulsar.listener.schema-type" , "avro" );
357
357
map .put ("spring.pulsar.listener.observation-enabled" , "true" );
358
- PulsarProperties .Listener properties = bindPropeties (map ).getListener ();
358
+ PulsarProperties .Listener properties = bindProperties (map ).getListener ();
359
359
assertThat (properties .getSchemaType ()).isEqualTo (SchemaType .AVRO );
360
360
assertThat (properties .isObservationEnabled ()).isTrue ();
361
361
}
@@ -373,7 +373,7 @@ void bind() {
373
373
map .put ("spring.pulsar.reader.subscription-name" , "my-subscription" );
374
374
map .put ("spring.pulsar.reader.subscription-role-prefix" , "sub-role" );
375
375
map .put ("spring.pulsar.reader.read-compacted" , "true" );
376
- PulsarProperties .Reader properties = bindPropeties (map ).getReader ();
376
+ PulsarProperties .Reader properties = bindProperties (map ).getReader ();
377
377
assertThat (properties .getName ()).isEqualTo ("my-reader" );
378
378
assertThat (properties .getTopics ()).containsExactly ("my-topic" );
379
379
assertThat (properties .getSubscriptionName ()).isEqualTo ("my-subscription" );
@@ -390,7 +390,7 @@ class TemplateProperties {
390
390
void bind () {
391
391
Map <String , String > map = new HashMap <>();
392
392
map .put ("spring.pulsar.template.observations-enabled" , "true" );
393
- PulsarProperties .Template properties = bindPropeties (map ).getTemplate ();
393
+ PulsarProperties .Template properties = bindProperties (map ).getTemplate ();
394
394
assertThat (properties .isObservationsEnabled ()).isTrue ();
395
395
}
396
396
@@ -403,7 +403,7 @@ class TransactionProperties {
403
403
void bind () {
404
404
Map <String , String > map = new HashMap <>();
405
405
map .put ("spring.pulsar.transaction.enabled" , "true" );
406
- PulsarProperties .Transaction properties = bindPropeties (map ).getTransaction ();
406
+ PulsarProperties .Transaction properties = bindProperties (map ).getTransaction ();
407
407
assertThat (properties .isEnabled ()).isTrue ();
408
408
}
409
409
0 commit comments