Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/net/spy/memcached/ArcusClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -1917,7 +1917,7 @@ public void gotTrimmedKey(String key, Object bkey) {
public CollectionFuture<Boolean> asyncBopUpsert(String key, long bkey,
byte[] elementFlag, Object value,
CollectionAttributes attributesForCreate) {
return asyncBopInsert(key, bkey, elementFlag, value, attributesForCreate, collectionTranscoder);
return asyncBopUpsert(key, bkey, elementFlag, value, attributesForCreate, collectionTranscoder);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,18 @@
*/
package net.spy.memcached.collection.btree;

import java.util.Map;

import net.spy.memcached.collection.BaseIntegrationTest;
import net.spy.memcached.collection.CollectionAttributes;
import net.spy.memcached.collection.Element;
import net.spy.memcached.internal.CollectionFuture;

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
Expand Down Expand Up @@ -58,4 +63,25 @@ void testUpsertNotExistsKey() {
fail(e.getMessage());
}
}

@Test
void upsertExistingElement() throws Exception {
// given
CollectionFuture<Boolean> future
= mc.asyncBopUpsert(KEY, BKEY, null, "INITIAL_VALUE", new CollectionAttributes());
boolean result = future.get();
assertTrue(result);

// when
future = mc.asyncBopUpsert(KEY, BKEY, null, "UPDATED_VALUE", null);
result = future.get();

// then
assertTrue(result);
CollectionFuture<Map<Long, Element<Object>>> futureToGet
= mc.asyncBopGet(KEY, BKEY, null, false, false);
Map<Long, Element<Object>> elements = futureToGet.get();
assertTrue(elements.containsKey(BKEY));
assertEquals("UPDATED_VALUE", elements.get(BKEY).getValue());
}
}