You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2019/08/27 12:07:40 UTC

[GitHub] [pulsar] borlandor commented on issue #5057: Can't publish messages with schema on Pulsar C++ client

borlandor commented on issue #5057: Can't publish messages with schema on Pulsar C++ client
URL: https://github.com/apache/pulsar/issues/5057#issuecomment-525271397
 
 
   C++ Test cases have no test of "producer.send" or "consumer.receive"
   SchemaTest.cc
   --------------------------------------------------------------------
   static std::string lookupUrl = "pulsar://localhost:6650";
   static const std::string exampleSchema =
       "{\"type\":\"record\",\"name\":\"Example\",\"namespace\":\"test\","
       "\"fields\":[{\"name\":\"a\",\"type\":\"int\"},{\"name\":\"b\",\"type\":\"int\"}]}";
   
   TEST(SchemaTest, testSchema) {
       ClientConfiguration config;
       Client client(lookupUrl);
       Result res;
   
       Producer producer;
       ProducerConfiguration producerConf;
       producerConf.setSchema(SchemaInfo(AVRO, "Avro", exampleSchema));
       res = client.createProducer("topic-avro", producerConf, producer);
       producer.close();
   
       ASSERT_EQ(ResultOk, res);
   
       // Creating producer with no schema on same topic should fail
       producerConf.setSchema(SchemaInfo(JSON, "Json", "{}"));
       res = client.createProducer("topic-avro", producerConf, producer);
       ASSERT_EQ(ResultIncompatibleSchema, res);
   
       // Creating producer with no schema on same topic should succeed
       // because standalone broker is configured by default to not
       // require the schema to be set
       res = client.createProducer("topic-avro", producer);
       ASSERT_EQ(ResultOk, res);
   
       ConsumerConfiguration consumerConf;
       Consumer consumer;
       // Subscribing with no schema will still succeed
       res = client.subscribe("topic-avro", "sub-1", consumerConf, consumer);
       ASSERT_EQ(ResultOk, res);
   
       // Subscribing with same Avro schema will succeed
       consumerConf.setSchema(SchemaInfo(AVRO, "Avro", exampleSchema));
       res = client.subscribe("topic-avro", "sub-2", consumerConf, consumer);
       ASSERT_EQ(ResultOk, res);
   
       // Subscribing with different schema type will fail
       consumerConf.setSchema(SchemaInfo(JSON, "Json", "{}"));
       res = client.subscribe("topic-avro", "sub-2", consumerConf, consumer);
       ASSERT_EQ(ResultIncompatibleSchema, res);
   }

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services