@Test public void testWriteHeader() throws IOException { final SchemaIdentifier schemaIdentifier = SchemaIdentifier.builder().id(123456L).version(2).build(); final RecordSchema recordSchema = createRecordSchema(schemaIdentifier); final ByteArrayOutputStream out = new ByteArrayOutputStream(); final SchemaAccessWriter schemaAccessWriter = new ConfluentSchemaRegistryWriter(); schemaAccessWriter.writeHeader(recordSchema, out); try (final ByteArrayInputStream bytesIn = new ByteArrayInputStream(out.toByteArray()); final DataInputStream in = new DataInputStream(bytesIn)) { Assert.assertEquals(0, in.readByte()); Assert.assertEquals((int) schemaIdentifier.getIdentifier().getAsLong(), in.readInt()); } }
@Override public void writeHeader(final RecordSchema schema, final OutputStream out) throws IOException { final SchemaIdentifier identifier = schema.getIdentifier(); final Long id = identifier.getIdentifier().getAsLong(); final ByteBuffer bb = ByteBuffer.allocate(5); bb.put((byte) 0); bb.putInt(id.intValue()); out.write(bb.array()); }
ConfluentSchemaRegistryWriter implements SchemaAccessWriter { @Override public void writeHeader(final RecordSchema schema, final OutputStream out) throws IOException { final SchemaIdentifier identifier = schema.getIdentifier(); final Long id = identifier.getIdentifier().getAsLong(); final ByteBuffer bb = ByteBuffer.allocate(5); bb.put((byte) 0); bb.putInt(id.intValue()); out.write(bb.array()); } }
ConfluentSchemaRegistryWriter implements SchemaAccessWriter { @Override public void writeHeader(final RecordSchema schema, final OutputStream out) throws IOException { final SchemaIdentifier identifier = schema.getIdentifier(); final Long id = identifier.getIdentifier().getAsLong(); final ByteBuffer bb = ByteBuffer.allocate(5); bb.put((byte) 0); bb.putInt(id.intValue()); out.write(bb.array()); }  }
ConfluentSchemaRegistryWriter implements SchemaAccessWriter { @Override public void writeHeader(final RecordSchema schema, final OutputStream out) throws IOException { final SchemaIdentifier identifier = schema.getIdentifier(); final Long id = identifier.getIdentifier().getAsLong(); final ByteBuffer bb = ByteBuffer.allocate(5); bb.put((byte) 0); bb.putInt(id.intValue()); out.write(bb.array()); }  @Override void writeHeader(final RecordSchema schema, final OutputStream out); @Override Map<String, String> getAttributes(final RecordSchema schema); @Override void validateSchema(RecordSchema schema); @Override Set<SchemaField> getRequiredSchemaFields(); }
ConfluentSchemaRegistryWriter implements SchemaAccessWriter { @Override public void writeHeader(final RecordSchema schema, final OutputStream out) throws IOException { final SchemaIdentifier identifier = schema.getIdentifier(); final Long id = identifier.getIdentifier().getAsLong(); final ByteBuffer bb = ByteBuffer.allocate(5); bb.put((byte) 0); bb.putInt(id.intValue()); out.write(bb.array()); }  @Override void writeHeader(final RecordSchema schema, final OutputStream out); @Override Map<String, String> getAttributes(final RecordSchema schema); @Override void validateSchema(RecordSchema schema); @Override Set<SchemaField> getRequiredSchemaFields();  }