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());
}
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"));
}
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"));
}
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"));
}
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());
}
}
Aggregations