當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。