本文整理汇总了Java中org.sdnplatform.sync.internal.store.IStore.put方法的典型用法代码示例。如果您正苦于以下问题:Java IStore.put方法的具体用法?Java IStore.put怎么用?Java IStore.put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.sdnplatform.sync.internal.store.IStore
的用法示例。
在下文中一共展示了IStore.put方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testGetVersions
import org.sdnplatform.sync.internal.store.IStore; //导入方法依赖的package包/类
@Test
public void testGetVersions() throws Exception {
List<K> keys = getKeys(2);
K key = keys.get(0);
V value = getValue();
IStore<K, V> store = getStore();
store.put(key, Versioned.value(value));
List<Versioned<V>> versioneds = store.get(key);
List<IVersion> versions = store.getVersions(key);
assertEquals(1, versioneds.size());
assertTrue(versions.size() > 0);
for(int i = 0; i < versions.size(); i++)
assertEquals(versioneds.get(0).getVersion(), versions.get(i));
assertEquals(0, store.getVersions(keys.get(1)).size());
}
示例2: testEmptyByteArray
import org.sdnplatform.sync.internal.store.IStore; //导入方法依赖的package包/类
@Test
public void testEmptyByteArray() throws Exception {
IStore<ByteArray, byte[]> store = getStore();
Versioned<byte[]> bytes = new Versioned<byte[]>(new byte[0]);
store.put(new ByteArray(new byte[0]), bytes);
List<Versioned<byte[]>> found = store.get(new ByteArray(new byte[0]));
assertEquals("Incorrect number of results.", 1, found.size());
bassertEquals("Get doesn't equal put.", bytes, found.get(0));
}
示例3: testPutNullValue
import org.sdnplatform.sync.internal.store.IStore; //导入方法依赖的package包/类
@Test
public void testPutNullValue() throws Exception {
IStore<K,V> store = getStore();
K key = getKey();
store.put(key, new Versioned<V>(null));
List<Versioned<V>> found = store.get(key);
assertEquals("Wrong number of values.", 1, found.size());
assertEquals("Returned non-null value.", null,
found.get(0).getValue());
}
示例4: testObsoletePutFails
import org.sdnplatform.sync.internal.store.IStore; //导入方法依赖的package包/类
private void testObsoletePutFails(String message,
IStore<K, V> store,
K key,
Versioned<V> versioned) throws SyncException {
VectorClock clock = (VectorClock) versioned.getVersion();
clock = clock.clone();
try {
store.put(key, versioned);
fail(message);
} catch(ObsoleteVersionException e) {
// this is good, but check that we didn't fuck with the version
assertEquals(clock, versioned.getVersion());
}
}
示例5: testFetchedEqualsPut
import org.sdnplatform.sync.internal.store.IStore; //导入方法依赖的package包/类
@Test
public void testFetchedEqualsPut() throws Exception {
K key = getKey();
IStore<K, V> store = getStore();
VectorClock clock = getClock(1, 1, 2, 3, 3, 4);
V value = getValue();
assertEquals("Store not empty at start!", 0, store.get(key).size());
Versioned<V> versioned = new Versioned<V>(value, clock);
store.put(key, versioned);
List<Versioned<V>> found = store.get(key);
assertEquals("Should only be one version stored.", 1, found.size());
assertTrue("Values not equal!", valuesEqual(versioned.getValue(), found.get(0).getValue()));
}
示例6: testVersionedPut
import org.sdnplatform.sync.internal.store.IStore; //导入方法依赖的package包/类
@Test
public void testVersionedPut() throws Exception {
K key = getKey();
IStore<K, V> store = getStore();
VectorClock clock = getClock(1, 1);
VectorClock clockCopy = clock.clone();
V value = getValue();
assertEquals("Store not empty at start!", 0, store.get(key).size());
Versioned<V> versioned = new Versioned<V>(value, clock);
// put initial version
store.put(key, versioned);
assertContains(store.get(key), versioned);
// test that putting obsolete versions fails
testObsoletePutFails("Put of identical version/value succeeded.",
store,
key,
new Versioned<V>(value, clockCopy));
testObsoletePutFails("Put of identical version succeeded.",
store,
key,
new Versioned<V>(getValue(), clockCopy));
testObsoletePutFails("Put of obsolete version succeeded.",
store,
key,
new Versioned<V>(getValue(), getClock(1)));
assertEquals("Should still only be one version in store.", store.get(key).size(), 1);
assertContains(store.get(key), versioned);
// test that putting a concurrent version succeeds
if(allowConcurrentOperations()) {
store.put(key, new Versioned<V>(getValue(), getClock(1, 2)));
assertEquals(2, store.get(key).size());
} else {
try {
store.put(key, new Versioned<V>(getValue(), getClock(1, 2)));
fail();
} catch(ObsoleteVersionException e) {
// expected
}
}
// test that putting an incremented version succeeds
Versioned<V> newest = new Versioned<V>(getValue(), getClock(1, 1, 2, 2));
store.put(key, newest);
assertContains(store.get(key), newest);
}