@Test
    public void compareAndPutTest() {
        final byte[] key = makeKey("put_test");
        final byte[] value = makeValue("put_test_value");
        this.kvStore.put(key, value, null);

        final byte[] update = makeValue("put_test_update");
        KVStoreClosure kvStoreClosure = new BaseKVStoreClosure() {
            @Override
            public void run(Status status) {
                assertEquals(status, Status.OK());
            }
        };
        this.kvStore.compareAndPut(key, value, update, kvStoreClosure);
        assertEquals(kvStoreClosure.getData(), Boolean.TRUE);
        byte[] newValue = new SyncKVStore<byte[]>() {
            @Override
            public void execute(RawKVStore kvStore, KVStoreClosure closure) {
                kvStore.get(key, closure);
            }
        }.apply(this.kvStore);
        assertArrayEquals(update, newValue);

        this.kvStore.compareAndPut(key, value, update, kvStoreClosure);
        assertEquals(kvStoreClosure.getData(), Boolean.FALSE);

        final byte[] testNullKey = makeKey("put_test_null");
        final byte[] testNullKeyValue = makeKey("put_test_update_null");
        this.kvStore.compareAndPut(testNullKey, null, testNullKeyValue, kvStoreClosure);
        byte[] newTestNullValue = new SyncKVStore<byte[]>() {
            @Override
            public void execute(RawKVStore kvStore, KVStoreClosure closure) {
                kvStore.get(testNullKey, closure);
            }
        }.apply(this.kvStore);
        assertArrayEquals(testNullKeyValue, newTestNullValue);
        this.kvStore.compareAndPut(testNullKey, testNullKeyValue, null, kvStoreClosure);
        newTestNullValue = new SyncKVStore<byte[]>() {
            @Override
            public void execute(RawKVStore kvStore, KVStoreClosure closure) {
                kvStore.get(testNullKey, closure);
            }
        }.apply(this.kvStore);
        assertArrayEquals(null, newTestNullValue);
    }
Test method: {@link RocksRawKVStore#compareAndPut(byte[], byte[], byte[], KVStoreClosure)}
jraft-rheakv/rheakv-core/src/test/java/com/alipay/sofa/jraft/rhea/storage/rocksdb/RocksKVStoreTest.java