use of io.confluent.kafka.schemaregistry.client.SchemaRegistryClient in project ksql by confluentinc.
the class JoinNodeTest method shouldBuildTableNodeWithCorrectAutoCommitOffsetPolicy.
@Test
public void shouldBuildTableNodeWithCorrectAutoCommitOffsetPolicy() {
setupTopicClientExpectations(1, 1);
buildJoin();
KsqlConfig ksqlConfig = mock(KsqlConfig.class);
KafkaTopicClient kafkaTopicClient = mock(KafkaTopicClient.class);
FunctionRegistry functionRegistry = mock(FunctionRegistry.class);
class RightTable extends PlanNode {
final Schema schema;
public RightTable(final PlanNodeId id, Schema schema) {
super(id);
this.schema = schema;
}
@Override
public Schema getSchema() {
return schema;
}
@Override
public Field getKeyField() {
return null;
}
@Override
public List<PlanNode> getSources() {
return null;
}
@Override
public SchemaKStream buildStream(StreamsBuilder builder, KsqlConfig ksqlConfig, KafkaTopicClient kafkaTopicClient, FunctionRegistry functionRegistry, Map<String, Object> props, SchemaRegistryClient schemaRegistryClient) {
if (props.containsKey(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG) && props.get(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG).toString().equalsIgnoreCase("EARLIEST")) {
return mock(SchemaKTable.class);
} else {
throw new KsqlException("auto.offset.reset should be set to EARLIEST.");
}
}
@Override
protected int getPartitions(KafkaTopicClient kafkaTopicClient) {
return 1;
}
}
RightTable rightTable = new RightTable(new PlanNodeId("1"), joinNode.getRight().getSchema());
JoinNode testJoinNode = new JoinNode(joinNode.getId(), joinNode.getType(), joinNode.getLeft(), rightTable, joinNode.getLeftKeyFieldName(), joinNode.getRightKeyFieldName(), joinNode.getLeftAlias(), joinNode.getRightAlias());
testJoinNode.tableForJoin(builder, ksqlConfig, kafkaTopicClient, functionRegistry, new HashMap<>(), new MockSchemaRegistryClient());
}
use of io.confluent.kafka.schemaregistry.client.SchemaRegistryClient in project ksql by confluentinc.
the class KsqlSchemaRegistryClientFactoryTest method shouldPickUpPrefixedSslConfig.
@Test
public void shouldPickUpPrefixedSslConfig() {
// Given:
final KsqlConfig config = config("ksql.schema.registry." + SslConfigs.SSL_PROTOCOL_CONFIG, "SSLv3");
final Map<String, Object> expectedConfigs = defaultConfigs();
expectedConfigs.put(SslConfigs.SSL_PROTOCOL_CONFIG, "SSLv3");
setUpMocksWithExpectedConfig(expectedConfigs);
// When:
final SchemaRegistryClient client = new KsqlSchemaRegistryClientFactory(config, restServiceSupplier, sslFactory).create();
// Then:
assertThat(client, is(notNullValue()));
EasyMock.verify(restService);
}
use of io.confluent.kafka.schemaregistry.client.SchemaRegistryClient in project ksql by confluentinc.
the class KsqlSchemaRegistryClientFactoryTest method shouldSetSocketFactoryWhenNoSpecificSslConfig.
@Test
public void shouldSetSocketFactoryWhenNoSpecificSslConfig() {
// Given:
final KsqlConfig config = config();
final Map<String, Object> expectedConfigs = defaultConfigs();
setUpMocksWithExpectedConfig(expectedConfigs);
// When:
final SchemaRegistryClient client = new KsqlSchemaRegistryClientFactory(config, restServiceSupplier, sslFactory).create();
// Then:
assertThat(client, is(notNullValue()));
EasyMock.verify(restService);
}
use of io.confluent.kafka.schemaregistry.client.SchemaRegistryClient in project ksql by confluentinc.
the class KsqlSchemaRegistryClientFactoryTest method shouldPickUpNonPrefixedSslConfig.
@Test
public void shouldPickUpNonPrefixedSslConfig() {
// Given:
final KsqlConfig config = config(SslConfigs.SSL_PROTOCOL_CONFIG, "SSLv3");
final Map<String, Object> expectedConfigs = defaultConfigs();
expectedConfigs.put(SslConfigs.SSL_PROTOCOL_CONFIG, "SSLv3");
setUpMocksWithExpectedConfig(expectedConfigs);
// When:
final SchemaRegistryClient client = new KsqlSchemaRegistryClientFactory(config, restServiceSupplier, sslFactory).create();
// Then:
assertThat(client, is(notNullValue()));
EasyMock.verify(restService);
}
use of io.confluent.kafka.schemaregistry.client.SchemaRegistryClient in project ksql by confluentinc.
the class AvroUtilTest method shouldFailForInvalidResultAvroSchema.
@Test
public void shouldFailForInvalidResultAvroSchema() throws IOException, RestClientException {
SchemaRegistryClient schemaRegistryClient = mock(SchemaRegistryClient.class);
KsqlTopic resultTopic = new KsqlTopic("testTopic", "testTopic", new KsqlAvroTopicSerDe());
Schema resultSchema = SerDeUtil.getSchemaFromAvro(ordersAveroSchemaStr);
PersistentQueryMetadata persistentQueryMetadata = new PersistentQueryMetadata("", null, null, "", null, DataSource.DataSourceType.KSTREAM, "", mock(KafkaTopicClient.class), resultSchema, resultTopic, null);
expect(schemaRegistryClient.testCompatibility(anyString(), anyObject())).andReturn(false);
replay(schemaRegistryClient);
try {
avroUtil.validatePersistentQueryResults(persistentQueryMetadata, schemaRegistryClient);
fail();
} catch (Exception e) {
assertThat("Incorrect exception message", "Cannot register avro schema for testTopic since " + "it is not valid for schema registry.", equalTo(e.getMessage()));
}
}
Aggregations