pulsar-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [pulsar] sijie commented on a change in pull request #4117: [pulsar-clients]Store key part of a KeyValue schema into pulsar message keys
Date Thu, 25 Apr 2019 13:40:39 GMT
sijie commented on a change in pull request #4117: [pulsar-clients]Store key part of a KeyValue
schema into pulsar message keys
URL: https://github.com/apache/pulsar/pull/4117#discussion_r278552339
 
 

 ##########
 File path: pulsar-client/src/test/java/org/apache/pulsar/client/impl/MessageImplTest.java
 ##########
 @@ -71,4 +78,48 @@ public void testGetProducerNameAssigned() {
         assertEquals("test-producer", msg.getProducerName());
     }
 
+    @Test
+    public void testGetProducerDataAssigned() {
+        MessageMetadata.Builder builder = MessageMetadata.newBuilder()
+                .setProducerName("test-producer");
+
+//        ByteBuffer payload = ByteBuffer.wrap(new byte[0]);
+        AvroSchema<SchemaTestUtils.Foo> fooSchema = AvroSchema.of(SchemaDefinition.<SchemaTestUtils.Foo>builder().withPojo(SchemaTestUtils.Foo.class).build());
+        AvroSchema<SchemaTestUtils.Bar> barSchema = AvroSchema.of(SchemaDefinition.<SchemaTestUtils.Bar>builder().withPojo(SchemaTestUtils.Bar.class).build());
+
+        Schema<KeyValue<SchemaTestUtils.Foo, SchemaTestUtils.Bar>> keyValueSchema
= Schema.KeyValue(fooSchema, barSchema);
+        SchemaTestUtils.Foo foo = new SchemaTestUtils.Foo();
+        foo.setField1("field1");
+        foo.setField2("field2");
+        foo.setField3(3);
+        SchemaTestUtils.Bar bar = new SchemaTestUtils.Bar();
+        bar.setField1(true);
+        Map<String, String> properties = Maps.newHashMap();
+
+        // // Check kv.encoding.type default, not set value
+        byte[] encodeBytes = keyValueSchema.encode(new KeyValue(foo, bar));
+        MessageImpl<KeyValue<SchemaTestUtils.Foo, SchemaTestUtils.Bar>> msg =
MessageImpl.create(builder, ByteBuffer.wrap(encodeBytes), keyValueSchema);
+        KeyValue<SchemaTestUtils.Foo, SchemaTestUtils.Bar> keyValue = msg.getValue();
+        assertEquals(keyValue.getKey(), foo);
+        assertEquals(keyValue.getValue(), bar);
 
 Review comment:
   the default is `INLINE`. so you need to check `builder.keyBytes` is not set.

----------------------------------------------------------------
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

Mime
View raw message