本文整理汇总了Java中io.teknek.tunit.TUnit类的典型用法代码示例。如果您正苦于以下问题:Java TUnit类的具体用法?Java TUnit怎么用?Java TUnit使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TUnit类属于io.teknek.tunit包,在下文中一共展示了TUnit类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: GrowOnlyCounterTest
import io.teknek.tunit.TUnit; //导入依赖的package包/类
@Test
public void GrowOnlyCounterTest(){
Consumer<Long> assertCountUpdated = count -> {
for (GossipManager client : clients){
TUnit.assertThat(() -> client.findCrdt(gCounterKey))
.afterWaitingAtMost(10, TimeUnit.SECONDS)
.isEqualTo(new GrowOnlyCounter(new GrowOnlyCounter.Builder(client).increment(count)));
}
};
//generate different increment
Object payload = new GrowOnlyCounter(new GrowOnlyCounter.Builder(clients.get(0)).increment(1L));
clients.get(0).merge(generateSharedMsg(gCounterKey, payload));
payload = new GrowOnlyCounter(new GrowOnlyCounter.Builder(clients.get(1)).increment(2L));
clients.get(1).merge(generateSharedMsg(gCounterKey, payload));
assertCountUpdated.accept((long) 3);
//update one
GrowOnlyCounter gc = (GrowOnlyCounter) clients.get(1).findCrdt(gCounterKey);
GrowOnlyCounter gc2 = new GrowOnlyCounter(gc,
new GrowOnlyCounter.Builder(clients.get(1)).increment(4L));
clients.get(1).merge(generateSharedMsg(gCounterKey, gc2));
assertCountUpdated.accept((long) 7);
}
示例2: aStatefulThingThatChanges
import io.teknek.tunit.TUnit; //导入依赖的package包/类
@Test
public void aStatefulThingThatChanges() throws InterruptedException{
/*
//The Enemy
Changing c = new Changing();
new Thread(c).start();
Thread.sleep(1000);
Assert.assertEquals(10, c.x);
*/
final Changing c = new Changing();
new Thread(c).start();
TUnit.assertThat( new Callable<Integer>() {
public Integer call() throws Exception {
return c.x;
}}).afterWaitingAtMost(2000, TimeUnit.MILLISECONDS).isEqualTo(10);
}
示例3: assertTwoAlive
import io.teknek.tunit.TUnit; //导入依赖的package包/类
private void assertTwoAlive(List<GossipManager> clients){
TUnit.assertThat(() -> {
int total = 0;
for (int i = 0; i < clients.size(); ++i) {
total += clients.get(i).getLiveMembers().size();
}
return total;
}).afterWaitingAtMost(20, TimeUnit.SECONDS).isEqualTo(2);
}
示例4: callableAssert
import io.teknek.tunit.TUnit; //导入依赖的package包/类
@Test
public void callableAssert() throws InterruptedException{
final Changing c = new Changing();
new Thread(c).start();
TUnit.assertThat( new Callable<Integer>() {
public Integer call() throws Exception {
return c.x;
}}).afterWaitingAtMost(2000, TimeUnit.MILLISECONDS).isNotEqualTo(11);
}
示例5: callableAssertToFail1
import io.teknek.tunit.TUnit; //导入依赖的package包/类
@Test
public void callableAssertToFail1() throws InterruptedException{
final Changing c = new Changing();
new Thread(c).start();
TUnit.assertThat( new Callable<Integer>() {
public Integer call() throws Exception {
return c.x;
}}).afterWaitingAtMost(2000, TimeUnit.MILLISECONDS).isNotEqualTo(10);
}
示例6: callableAssertToFail2
import io.teknek.tunit.TUnit; //导入依赖的package包/类
@Test
public void callableAssertToFail2() throws InterruptedException{
TUnit.assertThat( new Callable<Integer>() {
public Integer call() throws Exception {
return 5;
}}).afterWaitingAtMost(2000, TimeUnit.MILLISECONDS).isNotEqualTo(10);
}
示例7: callableAssertToFail3
import io.teknek.tunit.TUnit; //导入依赖的package包/类
@Test(expected=ComparisonFailure.class)
public void callableAssertToFail3() throws InterruptedException{
TUnit.assertThat( new Callable<Integer>() {
public Integer call() throws Exception {
return 5;
}}).afterWaitingAtMost(2000, TimeUnit.MILLISECONDS).isNotEqualTo(5);
}
示例8: callableAssertIsFunc
import io.teknek.tunit.TUnit; //导入依赖的package包/类
@Test
public void callableAssertIsFunc() throws InterruptedException{
final Changing c = new Changing();
new Thread(c).start();
TUnit.assertThat( new Callable<Integer>() {
public Integer call() throws Exception {
return c.x;
}}).is(isEqualTo(10));
}
示例9: assertDataIsRemoved
import io.teknek.tunit.TUnit; //导入依赖的package包/类
private void assertDataIsRemoved(GossipManager gm){
TUnit.assertThat(() -> gm.findPerNodeGossipData(myId, key)).equals(null);
TUnit.assertThat(() -> gm.findSharedGossipData(key)).equals(null);
}
示例10: assertMergedCrdt
import io.teknek.tunit.TUnit; //导入依赖的package包/类
private void assertMergedCrdt(String key, Object expected){
for (GossipManager client : clients){
TUnit.assertThat(() -> client.findCrdt(key).value())
.afterWaitingAtMost(10, TimeUnit.SECONDS).isEqualTo(expected);
}
}
示例11: test
import io.teknek.tunit.TUnit; //导入依赖的package包/类
@Test
public void test() throws ClientException, InterruptedException{
final Server[] servers = new Server[2];
TemporaryFolder [] tempFolders = { node1Folder, node2Folder};
Configuration [] cs = new Configuration[2];
for (int i = 0; i < cs.length; i++) {
cs[i] = TestUtil.aBasicConfiguration(tempFolders[i]);
cs[i].setTransportHost("127.0.0." + (i + 1));
cs[i].setClusterMembershipProperties(TestUtil.gossipPropertiesFor127Seed());
servers[i] = registerServer(new Server(cs[i]));
}
servers[0].init();
final MetaDataClient metaClient = new MetaDataClient(servers[0].getConfiguration().getTransportHost(), servers[0]
.getConfiguration().getTransportPort(), 10000, 10000);
createKeyspaceInformation(metaClient, servers);
Assert.assertEquals(servers[0].getClusterMembership().getLiveMembers().size(), 0);//We do not count ourselves
ColumnFamilyClient c = new ColumnFamilyClient(new Client(servers[0].getConfiguration().getTransportHost(), servers[0]
.getConfiguration().getTransportPort(),10000,10000));
Session session = c.createBuilder().withKeyspace("abc")
.withWriteConsistency(ConsistencyLevel.ALL, new HashMap<String, Object>())
.withReadConsistency(ConsistencyLevel.ALL, new HashMap<String, Object>())
.withStore("def").build();
for (int k = 0; k < 10; k++) {
session.put(k+"", k+"", k+"", 1);
}
servers[1].init();
TUnit.assertThat( new Callable<Integer>(){
public Integer call() throws Exception {
return servers[0].getClusterMembership().getLiveMembers().size();
}}).afterWaitingAtMost(10, TimeUnit.SECONDS).isEqualTo(1);
servers[1].join("abc", "127.0.0.1", "5");
Thread.sleep(1000);
Assert.assertEquals(servers[1].getServerId().getU().toString(),
servers[0].getCoordinator().getSponsorCoordinator().getProtege().getDestinationId());
insertDataOverClient(session);
assertDataIsDistributed(servers);
TUnit.assertThat( new Callable<Integer>(){
@SuppressWarnings("unchecked")
public Integer call() throws Exception {
Map<String,String> keyspaceMembers = (Map<String, String>) metaClient.getKeyspaceMetadata("abc").get(TokenRouter.TOKEN_MAP_KEY);
return keyspaceMembers.size();
}}).afterWaitingAtMost(5, TimeUnit.SECONDS).isEqualTo(2);
metaClient.shutdown();
}