Search in sources :

Example 26 with ConfigException

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

the class ListDeserializerTest method testListKeyDeserializerNoArgConstructorsShouldThrowConfigExceptionDueListClassNotFound.

@Test
public void testListKeyDeserializerNoArgConstructorsShouldThrowConfigExceptionDueListClassNotFound() {
    props.put(CommonClientConfigs.DEFAULT_LIST_KEY_SERDE_TYPE_CLASS, nonExistingClass);
    props.put(CommonClientConfigs.DEFAULT_LIST_KEY_SERDE_INNER_CLASS, Serdes.StringSerde.class);
    final ConfigException exception = assertThrows(ConfigException.class, () -> listDeserializer.configure(props, true));
    assertEquals("Invalid value " + nonExistingClass + " for configuration " + CommonClientConfigs.DEFAULT_LIST_KEY_SERDE_TYPE_CLASS + ": Deserializer's list class " + "\"" + nonExistingClass + "\" could not be found.", exception.getMessage());
}
Also used : ConfigException(org.apache.kafka.common.config.ConfigException) Test(org.junit.jupiter.api.Test)

Example 27 with ConfigException

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

the class ConnectorConfigTest method unconfiguredTransform.

@Test
public void unconfiguredTransform() {
    Map<String, String> props = new HashMap<>();
    props.put("name", "test");
    props.put("connector.class", TestConnector.class.getName());
    props.put("transforms", "a");
    props.put("transforms.a.type", SimpleTransformation.class.getName());
    ConfigException e = assertThrows(ConfigException.class, () -> new ConnectorConfig(MOCK_PLUGINS, props));
    assertTrue(e.getMessage().contains("Missing required configuration \"transforms.a.magic.number\" which"));
}
Also used : HashMap(java.util.HashMap) ConfigException(org.apache.kafka.common.config.ConfigException) Test(org.junit.Test)

Example 28 with ConfigException

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

the class ConnectorConfigTest method emptyConnectorName.

@Test
public void emptyConnectorName() {
    Map<String, String> props = new HashMap<>();
    props.put("name", "");
    props.put("connector.class", TestConnector.class.getName());
    ConfigException e = assertThrows(ConfigException.class, () -> new ConnectorConfig(MOCK_PLUGINS, props));
    assertTrue(e.getMessage().contains("String may not be empty"));
}
Also used : HashMap(java.util.HashMap) ConfigException(org.apache.kafka.common.config.ConfigException) Test(org.junit.Test)

Example 29 with ConfigException

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

the class ConnectorConfigTest method wrongPredicateType.

@Test
public void wrongPredicateType() {
    Map<String, String> props = new HashMap<>();
    props.put("name", "test");
    props.put("connector.class", TestConnector.class.getName());
    props.put("transforms", "a");
    props.put("transforms.a.type", SimpleTransformation.class.getName());
    props.put("transforms.a.magic.number", "42");
    props.put("transforms.a.predicate", "my-pred");
    props.put("predicates", "my-pred");
    props.put("predicates.my-pred.type", TestConnector.class.getName());
    ConfigException e = assertThrows(ConfigException.class, () -> new ConnectorConfig(MOCK_PLUGINS, props));
    assertTrue(e.getMessage().contains("Not a Predicate"));
}
Also used : HashMap(java.util.HashMap) ConfigException(org.apache.kafka.common.config.ConfigException) Test(org.junit.Test)

Example 30 with ConfigException

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

the class KafkaProducerTest method testConstructorWithNotStringKey.

@Test
public void testConstructorWithNotStringKey() {
    Properties props = new Properties();
    props.setProperty(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9999");
    props.put(1, "not string key");
    try (KafkaProducer<?, ?> ff = new KafkaProducer<>(props, new StringSerializer(), new StringSerializer())) {
        fail("Constructor should throw exception");
    } catch (ConfigException e) {
        assertTrue(e.getMessage().contains("not string key"), "Unexpected exception message: " + e.getMessage());
    }
}
Also used : ConfigException(org.apache.kafka.common.config.ConfigException) Properties(java.util.Properties) StringSerializer(org.apache.kafka.common.serialization.StringSerializer) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) 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