当前位置: 首页>>代码示例>>Java>>正文


Java TUnit类代码示例

本文整理汇总了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);
}
 
开发者ID:apache,项目名称:incubator-gossip,代码行数:26,代码来源:DataTest.java

示例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);
}
 
开发者ID:edwardcapriolo,项目名称:tunit,代码行数:17,代码来源:TUnitTests.java

示例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);
}
 
开发者ID:apache,项目名称:incubator-gossip,代码行数:10,代码来源:SignedMessageTest.java

示例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);
}
 
开发者ID:edwardcapriolo,项目名称:tunit,代码行数:10,代码来源:TUnitTests.java

示例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);
}
 
开发者ID:edwardcapriolo,项目名称:tunit,代码行数:10,代码来源:TUnitTests.java

示例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);
}
 
开发者ID:edwardcapriolo,项目名称:tunit,代码行数:8,代码来源:TUnitTests.java

示例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);
}
 
开发者ID:edwardcapriolo,项目名称:tunit,代码行数:8,代码来源:TUnitTests.java

示例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));
}
 
开发者ID:edwardcapriolo,项目名称:tunit,代码行数:10,代码来源:TUnitTests.java

示例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);
}
 
开发者ID:apache,项目名称:incubator-gossip,代码行数:5,代码来源:DataReaperTest.java

示例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);
  }
}
 
开发者ID:apache,项目名称:incubator-gossip,代码行数:7,代码来源:DataTest.java

示例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();
}
 
开发者ID:edwardcapriolo,项目名称:nibiru,代码行数:48,代码来源:SponsorTest.java


注:本文中的io.teknek.tunit.TUnit类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。