Package net.tomp2p.futures

Examples of net.tomp2p.futures.FuturePut.awaitUninterruptibly()


    // create meta data
    data.duplicateMeta();
    // put meta using content content protection key 1 to sign message
    FuturePut futurePutMeta = p1.put(lKey).setDomainKey(dKey).putMeta().setData(cKey, data)
        .setVersionKey(vKey).keyPair(keyPair1).start();
    futurePutMeta.awaitUninterruptibly();
    Assert.assertTrue(futurePutMeta.isSuccess());

    // verify change
    retData = p1.get(lKey).setDomainKey(dKey).setContentKey(cKey).setVersionKey(vKey).start()
        .awaitUninterruptibly().getData();
View Full Code Here


    data = new Data("data2").setProtectedEntry();
    data.ttlSeconds(ttl).basedOn(bKey).sign(keyPair2, factory);
    // put using content wrong protection keys 1 to sign message
    FuturePut futureOverwrite3 = p1.put(lKey).setDomainKey(dKey).setData(cKey, data).setVersionKey(vKey)
        .keyPair(keyPair1).start();
    futureOverwrite3.awaitUninterruptibly();
    Assert.assertFalse(futureOverwrite3.isSuccess());

    // verify that nothing changed
    retData = p1.get(lKey).setDomainKey(dKey).setContentKey(cKey).setVersionKey(vKey).start()
        .awaitUninterruptibly().getData();
View Full Code Here

    // put version 1 with protection keys 1
    Data data1 = new Data("data1").setProtectedEntry();
    Number160 vKey1 = Number160.ZERO;
    FuturePut futurePut1 = p1.put(lKey).setData(cKey, data1).setDomainKey(dKey).setVersionKey(vKey1)
        .keyPair(keyPair1).start();
    futurePut1.awaitUninterruptibly();
    assertTrue(futurePut1.isSuccess());

    // verify put of version 1
    Data retData = p2.get(lKey).setDomainKey(dKey).setContentKey(cKey).setVersionKey(vKey1).start()
        .awaitUninterruptibly().getData();
View Full Code Here

   
    // try to overwrite version 1 without protection keys (expected to fail)
    Data data1A = new Data("data1A");
    FuturePut futurePut1A = p1.put(lKey).setData(cKey, data1A).setDomainKey(dKey).setVersionKey(vKey1)
        .start();
    futurePut1A.awaitUninterruptibly();
    assertFalse(futurePut1A.isSuccess());

    // verify that nothing changed
    retData = p2.get(lKey).setDomainKey(dKey).setContentKey(cKey).setVersionKey(vKey1).start()
        .awaitUninterruptibly().getData();
View Full Code Here

    // try to overwrite version 1 with wrong protection keys 2 (expected to fail)
    Data data1B = new Data("data1B").setProtectedEntry();
    FuturePut futurePut1B = p1.put(lKey).setData(cKey, data1B).setDomainKey(dKey).setVersionKey(vKey1)
        .keyPair(keyPair2).start();
    futurePut1B.awaitUninterruptibly();
    assertFalse(futurePut1B.isSuccess());

    // verify that nothing changed
    retData = p2.get(lKey).setDomainKey(dKey).setContentKey(cKey).setVersionKey(vKey1).start()
        .awaitUninterruptibly().getData();
View Full Code Here

    // overwrite version 1 with protection keys 1
    Data data1Overwrite = new Data("data1Overwrite").setProtectedEntry();
    FuturePut futurePutOverwrite = p1.put(lKey).setData(cKey, data1Overwrite).setDomainKey(dKey)
        .setVersionKey(vKey1).keyPair(keyPair1).start();
    futurePutOverwrite.awaitUninterruptibly();
    assertTrue(futurePutOverwrite.isSuccess());

    // verify overwrite
    retData = p2.get(lKey).setDomainKey(dKey).setContentKey(cKey).setVersionKey(vKey1).start()
        .awaitUninterruptibly().getData();
View Full Code Here

    Data data2 = new Data("data2").basedOn(vKey1).setProtectedEntry();
    // version 2 takes new version key
    Number160 vKey2 = Number160.createHash("version2");
    FuturePut futurePut2 = p1.put(lKey).setData(cKey, data2).setDomainKey(dKey).setVersionKey(vKey2)
        .keyPair(keyPair2).start();
    futurePut2.awaitUninterruptibly();
    assertFalse(futurePut2.isSuccess());

    // verify no put of version 2
    assertNull(p2.get(lKey).setContentKey(cKey).setVersionKey(vKey2).setDomainKey(dKey).start()
        .awaitUninterruptibly().getData());
View Full Code Here

    // put new version 3 (basing on version 1) with correct protection keys 1
    Data data3 = new Data("data3").basedOn(vKey1).setProtectedEntry();
    Number160 vKey3 = Number160.createHash("version3");
    FuturePut futurePut3 = p1.put(lKey).setData(cKey, data3).setDomainKey(dKey).setVersionKey(vKey3)
        .keyPair(keyPair1).start();
    futurePut3.awaitUninterruptibly();
    assertTrue(futurePut3.isSuccess());

    // verify put of version 3
    assertEquals("data3",
        (String) p2.get(lKey).setContentKey(cKey).setVersionKey(vKey3).setDomainKey(dKey).start()
View Full Code Here

    // (expected to fail)
    Data dataX = new Data("dataX").setProtectedEntry();
    Number160 vKeyX = Number160.createHash("versionX");
    FuturePut futurePut4 = p1.put(lKey).setData(cKey, dataX).setDomainKey(dKey).setVersionKey(vKeyX)
        .keyPair(keyPair2).start();
    futurePut4.awaitUninterruptibly();
    assertFalse(futurePut4.isSuccess());

    // verify no put of version X
    assertNull(p2.get(lKey).setContentKey(cKey).setVersionKey(vKeyX).setDomainKey(dKey).start()
        .awaitUninterruptibly().getData());
View Full Code Here

    // try to put random version Y in version key range of version 1 and 3 without protection keys
    // (expected to fail)
    Data dataY = new Data("dataY").setProtectedEntry();
    Number160 vKeyY = Number160.createHash("versionX");
    futurePut4 = p1.put(lKey).setData(cKey, dataY).setDomainKey(dKey).setVersionKey(vKeyY).start();
    futurePut4.awaitUninterruptibly();
    assertFalse(futurePut4.isSuccess());

    // verify no put of version Y
    assertNull(p2.get(lKey).setContentKey(cKey).setVersionKey(vKeyY).setDomainKey(dKey).start()
        .awaitUninterruptibly().getData());
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.