Search in sources :

Example 21 with ConfigException

use of org.apache.kafka.common.config.ConfigException in project kafka by apache.

the class ListSerializerTest method testListValueSerializerShouldThrowConfigExceptionDueAlreadyInitialized.

@Test
public void testListValueSerializerShouldThrowConfigExceptionDueAlreadyInitialized() {
    props.put(CommonClientConfigs.DEFAULT_LIST_VALUE_SERDE_INNER_CLASS, Serdes.StringSerde.class);
    final ListSerializer<Integer> initializedListSerializer = new ListSerializer<>(Serdes.Integer().serializer());
    final ConfigException exception = assertThrows(ConfigException.class, () -> initializedListSerializer.configure(props, false));
    assertEquals("List serializer was already initialized using a non-default constructor", exception.getMessage());
}
Also used : ConfigException(org.apache.kafka.common.config.ConfigException) Test(org.junit.jupiter.api.Test)

Example 22 with ConfigException

use of org.apache.kafka.common.config.ConfigException in project kafka by apache.

the class ListDeserializerTest method testListValueDeserializerNoArgConstructorsShouldThrowConfigExceptionDueMissingTypeClassProp.

@Test
public void testListValueDeserializerNoArgConstructorsShouldThrowConfigExceptionDueMissingTypeClassProp() {
    props.put(CommonClientConfigs.DEFAULT_LIST_VALUE_SERDE_INNER_CLASS, Serdes.StringSerde.class);
    final ConfigException exception = assertThrows(ConfigException.class, () -> listDeserializer.configure(props, false));
    assertEquals("Not able to determine the list class because " + "it was neither passed via the constructor nor set in the config.", exception.getMessage());
}
Also used : ConfigException(org.apache.kafka.common.config.ConfigException) Test(org.junit.jupiter.api.Test)

Example 23 with ConfigException

use of org.apache.kafka.common.config.ConfigException in project kafka by apache.

the class ListDeserializerTest method testListValueDeserializerShouldThrowConfigExceptionDueAlreadyInitialized.

@Test
public void testListValueDeserializerShouldThrowConfigExceptionDueAlreadyInitialized() {
    props.put(CommonClientConfigs.DEFAULT_LIST_VALUE_SERDE_TYPE_CLASS, ArrayList.class);
    props.put(CommonClientConfigs.DEFAULT_LIST_VALUE_SERDE_INNER_CLASS, Serdes.StringSerde.class);
    final ListDeserializer<Integer> initializedListDeserializer = new ListDeserializer<>(ArrayList.class, Serdes.Integer().deserializer());
    final ConfigException exception = assertThrows(ConfigException.class, () -> initializedListDeserializer.configure(props, true));
    assertEquals("List deserializer was already initialized using a non-default constructor", exception.getMessage());
}
Also used : ConfigException(org.apache.kafka.common.config.ConfigException) Test(org.junit.jupiter.api.Test)

Example 24 with ConfigException

use of org.apache.kafka.common.config.ConfigException in project kafka by apache.

the class ListDeserializerTest method testListKeyDeserializerShouldThrowConfigExceptionDueAlreadyInitialized.

@Test
public void testListKeyDeserializerShouldThrowConfigExceptionDueAlreadyInitialized() {
    props.put(CommonClientConfigs.DEFAULT_LIST_KEY_SERDE_TYPE_CLASS, ArrayList.class);
    props.put(CommonClientConfigs.DEFAULT_LIST_KEY_SERDE_INNER_CLASS, Serdes.StringSerde.class);
    final ListDeserializer<Integer> initializedListDeserializer = new ListDeserializer<>(ArrayList.class, Serdes.Integer().deserializer());
    final ConfigException exception = assertThrows(ConfigException.class, () -> initializedListDeserializer.configure(props, true));
    assertEquals("List deserializer was already initialized using a non-default constructor", exception.getMessage());
}
Also used : ConfigException(org.apache.kafka.common.config.ConfigException) Test(org.junit.jupiter.api.Test)

Example 25 with ConfigException

use of org.apache.kafka.common.config.ConfigException in project kafka by apache.

the class ListDeserializerTest method testListValueDeserializerNoArgConstructorsShouldThrowConfigExceptionDueMissingInnerClassProp.

@Test
public void testListValueDeserializerNoArgConstructorsShouldThrowConfigExceptionDueMissingInnerClassProp() {
    props.put(CommonClientConfigs.DEFAULT_LIST_VALUE_SERDE_TYPE_CLASS, ArrayList.class);
    final ConfigException exception = assertThrows(ConfigException.class, () -> listDeserializer.configure(props, false));
    assertEquals("Not able to determine the inner serde class because " + "it was neither passed via the constructor nor set in the config.", exception.getMessage());
}
Also used : ConfigException(org.apache.kafka.common.config.ConfigException) Test(org.junit.jupiter.api.Test)

Aggregations

ConfigException (org.apache.kafka.common.config.ConfigException)136 HashMap (java.util.HashMap)29 Test (org.junit.jupiter.api.Test)28 Test (org.junit.Test)20 Properties (java.util.Properties)10 KafkaException (org.apache.kafka.common.KafkaException)10 ArrayList (java.util.ArrayList)9 List (java.util.List)9 Pattern (java.util.regex.Pattern)9 Serde (org.apache.kafka.common.serialization.Serde)8 SimpleConfig (org.apache.kafka.connect.transforms.util.SimpleConfig)8 File (java.io.File)7 SSLContext (javax.net.ssl.SSLContext)7 Map (java.util.Map)6 ByteArraySerializer (org.apache.kafka.common.serialization.ByteArraySerializer)6 KeyStore (java.security.KeyStore)5 KeyManagerFactory (javax.net.ssl.KeyManagerFactory)5 TrustManagerFactory (javax.net.ssl.TrustManagerFactory)5 ConfigDef (org.apache.kafka.common.config.ConfigDef)5 IOException (java.io.IOException)4