Search in sources :

Example 91 with ConfigException

use of org.apache.kafka.common.config.ConfigException in project apache-kafka-on-k8s by banzaicloud.

the class TimeWindowedDeserializer method configure.

@SuppressWarnings("unchecked")
@Override
public void configure(final Map<String, ?> configs, final boolean isKey) {
    if (inner == null) {
        final String propertyName = isKey ? StreamsConfig.DEFAULT_WINDOWED_KEY_SERDE_INNER_CLASS : StreamsConfig.DEFAULT_WINDOWED_VALUE_SERDE_INNER_CLASS;
        final String value = (String) configs.get(propertyName);
        try {
            inner = Serde.class.cast(Utils.newInstance(value, Serde.class)).deserializer();
            inner.configure(configs, isKey);
        } catch (final ClassNotFoundException e) {
            throw new ConfigException(propertyName, value, "Serde class " + value + " could not be found.");
        }
    }
}
Also used : Serde(org.apache.kafka.common.serialization.Serde) ConfigException(org.apache.kafka.common.config.ConfigException)

Example 92 with ConfigException

use of org.apache.kafka.common.config.ConfigException in project apache-kafka-on-k8s by banzaicloud.

the class StreamsPartitionAssignorTest method shouldThrowExceptionIfApplicationServerConfigIsNotHostPortPair.

@Test
public void shouldThrowExceptionIfApplicationServerConfigIsNotHostPortPair() throws Exception {
    builder.setApplicationId(applicationId);
    mockTaskManager(Collections.<TaskId>emptySet(), Collections.<TaskId>emptySet(), UUID.randomUUID(), builder);
    partitionAssignor.setInternalTopicManager(new MockInternalTopicManager(streamsConfig, mockClientSupplier.restoreConsumer));
    try {
        configurePartitionAssignor(Collections.singletonMap(StreamsConfig.APPLICATION_SERVER_CONFIG, (Object) "localhost"));
        Assert.fail("expected to an exception due to invalid config");
    } catch (ConfigException e) {
    // pass
    }
}
Also used : MockInternalTopicManager(org.apache.kafka.test.MockInternalTopicManager) ConfigException(org.apache.kafka.common.config.ConfigException) StreamsBuilderTest(org.apache.kafka.streams.StreamsBuilderTest) Test(org.junit.Test)

Example 93 with ConfigException

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

the class ConnectorConfigTest method abstractPredicate.

@Test
public void abstractPredicate() {
    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", AbstractTestPredicate.class.getName());
    props.put("predicates.my-pred.int", "84");
    ConfigException e = assertThrows(ConfigException.class, () -> new ConnectorConfig(MOCK_PLUGINS, props));
    assertTrue(e.getMessage().contains("Predicate is abstract and cannot be created"));
}
Also used : HashMap(java.util.HashMap) ConfigException(org.apache.kafka.common.config.ConfigException) Test(org.junit.Test)

Example 94 with ConfigException

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

the class ConnectorConfigTest method negatedButNoPredicate.

@Test
public void negatedButNoPredicate() {
    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.negate", "true");
    ConfigException e = assertThrows(ConfigException.class, () -> new ConnectorConfig(MOCK_PLUGINS, props));
    assertTrue(e.getMessage().contains("there is no config 'transforms.a.predicate' defining a predicate to be negated"));
}
Also used : HashMap(java.util.HashMap) ConfigException(org.apache.kafka.common.config.ConfigException) Test(org.junit.Test)

Example 95 with ConfigException

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

the class ConnectorConfigTest method misconfiguredTransform.

@Test
public void misconfiguredTransform() {
    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", "40");
    ConfigException e = assertThrows(ConfigException.class, () -> new ConnectorConfig(MOCK_PLUGINS, props));
    assertTrue(e.getMessage().contains("Value must be at least 42"));
}
Also used : HashMap(java.util.HashMap) ConfigException(org.apache.kafka.common.config.ConfigException) Test(org.junit.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