DbusEvent { public abstract byte[] schemaId();  abstract boolean isExtReplicatedEvent(); abstract boolean isValid(); abstract boolean isControlMessage(); abstract boolean isPrivateControlMessage(); abstract boolean isCheckpointMessage(); abstract boolean isKeyNumber(); abstract boolean isKeyString(); abstract boolean isKeySchema(); abstract boolean isSCNRegressMessage(); abstract boolean isTraceEnabled(); abstract boolean isEndOfPeriodMarker(); abstract DbusOpcode getOpcode(); abstract long timestampInNanos(); abstract int size(); abstract long sequence(); abstract long key(); @Deprecated abstract int keyLength(); abstract byte[] keyBytes(); @Deprecated abstract short srcId(); abstract int getSourceId(); @Deprecated abstract short physicalPartitionId(); @Deprecated abstract short logicalPartitionId(); abstract short getPartitionId(); abstract byte[] schemaId(); abstract void schemaId(byte[] md5); abstract int valueLength(); abstract ByteBuffer value(); abstract ByteBuffer getRawBytes(); abstract DbusEventPart getPayloadPart(); abstract DbusEventPart getPayloadMetadataPart(); abstract DbusEventPart getKeyPart(); final static int MD5_DIGEST_LEN; final static int CRC32_DIGEST_LEN; }
@Test public void testSchemaVersion() throws KeyTypeNotImplementedException { final short SCHEMA_VERSION = 152; String randomValue = RngUtils.randomString(20); ByteBuffer serializationBuffer = ByteBuffer.allocate(1000).order(_eventV1Factory.getByteOrder()); ByteBuffer buffer = ByteBuffer.allocate(16); buffer.put(schemaId); buffer.flip(); buffer.putShort(SCHEMA_VERSION); buffer.flip(); byte [] schemaVersion = buffer.array(); DbusEventInfo eventInfo = new DbusEventInfo(DbusOpcode.UPSERT, 0L, (short)0, partitionId, timeStamp, srcId, schemaVersion, randomValue.getBytes(Charset.defaultCharset()), false, false); eventInfo.setEventSerializationVersion(DbusEventFactory.DBUS_EVENT_V1); DbusEventFactory.serializeEvent(new DbusEventKey(key), serializationBuffer, eventInfo); DbusEventInternalReadable e = _eventV1Factory.createReadOnlyDbusEventFromBuffer(serializationBuffer, 0); assertEquals("SchemaVersion matches", SCHEMA_VERSION,e.schemaVersion()); assertTrue("SchemaId doesn't match", !Arrays.equals(schemaId, e.schemaId())); assertTrue("SchemaId (14 bytes) matches", Arrays.equals(Arrays.copyOfRange(schemaId, 2, schemaId.length), Arrays.copyOfRange(e.schemaId(), 2, schemaId.length))); }