diff --git a/java/test/src/main/java/org/ray/api/test/PlasmaStoreTest.java b/java/test/src/main/java/org/ray/api/test/PlasmaStoreTest.java new file mode 100644 index 000000000000..726bad3da97c --- /dev/null +++ b/java/test/src/main/java/org/ray/api/test/PlasmaStoreTest.java @@ -0,0 +1,27 @@ +package org.ray.api.test; + +import org.apache.arrow.plasma.PlasmaClient; +import org.apache.arrow.plasma.exceptions.DuplicateObjectException; + +import org.ray.api.Ray; +import org.ray.api.id.UniqueId; +import org.ray.runtime.AbstractRayRuntime; +import org.testng.Assert; +import org.testng.annotations.Test; + +public class PlasmaStoreTest extends BaseTest { + + @Test + public void testPutWithDuplicateId() { + UniqueId objectId = UniqueId.randomId(); + AbstractRayRuntime runtime = (AbstractRayRuntime) Ray.internal(); + PlasmaClient store = new PlasmaClient(runtime.getRayConfig().objectStoreSocketName, "", 0); + store.put(objectId.getBytes(), new byte[]{}, new byte[]{}); + try { + store.put(objectId.getBytes(), new byte[]{}, new byte[]{}); + Assert.fail("This line shouldn't be reached."); + } catch (DuplicateObjectException e) { + // Putting 2 objects with duplicate ID should throw DuplicateObjectException. + } + } +}