public void testKeyOnlyWrittenOnceOnOriginator() throws Exception {
final Cache<MagicKey, String> cache1 = cache(0, CACHE_NAME);
final Cache<MagicKey, String> cache2 = cache(1, CACHE_NAME);
final CyclicBarrier barrier = new CyclicBarrier(2);
cache1.getAdvancedCache().addInterceptor(new BaseCustomInterceptor() {
@Override
public Object visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable {
if (!ctx.isOriginLocal()) {
// wait first before the check
barrier.await(10, TimeUnit.SECONDS);