com.tc.util.Assert.fail()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(6.5k)|赞(0)|评价(0)|浏览(201)

本文整理了Java中com.tc.util.Assert.fail()方法的一些代码示例,展示了Assert.fail()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Assert.fail()方法的具体详情如下:
包路径:com.tc.util.Assert
类名称:Assert
方法名:fail

Assert.fail介绍

[英]Throw assertion error with generic message
[中]使用泛型消息抛出断言错误

代码示例

代码示例来源:origin: ehcache/ehcache3

private void doSyncAndPut(PersistentCacheManager cacheManager) throws InterruptedException {
 String customValue = "value";
 Cache<String, Boolean> synCache = cacheManager.getCache(SYN_CACHE_NAME, String.class, Boolean.class);
 Cache<Long, String> customValueCache = cacheManager.getCache(CLUSTERED_CACHE_NAME, Long.class, String.class);
 parallelPuts(customValueCache);
 String firstClientStartKey = "first_client_start", firstClientEndKey = "first_client_end";
 if (synCache.putIfAbsent(firstClientStartKey, true) == null) {
  customValueCache.put(1L, customValue);
  assertThat(customValueCache.get(1L), is(customValue));
  synCache.put(firstClientEndKey, true);
 } else {
  int retry = 0, maxRetryCount = 30;
  while (++retry <= maxRetryCount && synCache.get(firstClientEndKey) == null) {
   Thread.sleep(1000L);
  }
  if (retry > maxRetryCount) {
   Assert.fail("Couldn't find " + firstClientEndKey + " in synCache after " + maxRetryCount + " retries!");
  }
  assertThat(customValueCache.get(1L), is(customValue));
 }
}

代码示例来源:origin: org.terracotta/terracotta-ee

@Override
public void discoveryHandler(EventContext context) {
 Assert.fail();
}

代码示例来源:origin: org.terracotta/terracotta-ee

@Override
public Node getLocalNode() {
 Assert.fail();
 return null;
}

代码示例来源:origin: org.terracotta/terracotta-l1

@Override
public synchronized void unpinLock(long awardID) {
 if (isAwardValid(awardID)) {
  if (pinned == 0) Assert.fail();
  pinned--;
 }
}

代码示例来源:origin: org.terracotta/terracotta-l1-ee

@Override
public synchronized void unpinLock(long awardID) {
 if (isAwardValid(awardID)) {
  if (pinned == 0) Assert.fail();
  pinned--;
 }
}

代码示例来源:origin: org.terracotta/terracotta-ee

@Override
protected int clearReferences(final Object pojo, final int toClear) {
 if (!(pojo instanceof Clearable)) {
  Assert.fail("TCObjectLogical.clearReferences expected Clearable but got "
        + (pojo == null ? "null" : pojo.getClass().getName()));
 }
 final Clearable clearable = (Clearable) pojo;
 return clearable.__tc_clearReferences(toClear);
}

代码示例来源:origin: org.terracotta.modules/tim-ehcache-commons

public Object put(final Object key, final Element value) {
 if(config.isLoggingEnabled()) {
  logger.info("Put [" + key + ", " + value + "]");
 }
 if(key == null) {
  Assert.fail("Cannot add cache element with null key");
 }
 if(value == null) {
  Assert.fail("Cannot add cache element with null value");
 }
 // CacheData cd = new CacheData(value, maxIdleTimeoutMillis, maxTTLMillis);
 // cd.accessed();
 int storeIndex = getStoreIndex(key);
 Element rv = (Element) store[storeIndex].put(key, value);
 updateExpireTime(key, value);
 return rv;
}

代码示例来源:origin: org.terracotta.modules/tim-ehcache-commons

public void putData(final Object key, final Element value) {
 if(config.isLoggingEnabled()) {
  logger.info("PutData [" + key + ", " + value + "]");
 }
 if (key == null) {
  Assert.fail("Cannot add cache element with null key");
 }
 if (value == null) {
  Assert.fail("Cannot add cache element with null value");
 }
 int storeIndex = getStoreIndex(key);
 ((TCMap) store[storeIndex]).__tc_put_logical(key, value);
 updateExpireTime(key, value);
}

代码示例来源:origin: org.terracotta/terracotta-ee

@Override
public void handleEvent(final EventContext context) {
 if (context instanceof NodesWithObjectsMessage) {
  this.clusterMetaDataManager.handleMessage((NodesWithObjectsMessage)context);
 } else if (context instanceof KeysForOrphanedValuesMessage) {
  this.clusterMetaDataManager.handleMessage((KeysForOrphanedValuesMessage)context);
 } else if (context instanceof NodeMetaDataMessage) {
  this.clusterMetaDataManager.handleMessage((NodeMetaDataMessage)context);
 } else if (context instanceof NodesWithKeysMessage) {
  this.clusterMetaDataManager.handleMessage((NodesWithKeysMessage)context);
 } else {
  Assert.fail("Unknown event type "+context.getClass().getName());
 }
}

代码示例来源:origin: org.terracotta.modules/tim-ehcache-commons

private void removeInternal(final Object key) {
 if(key == null) {
  Assert.fail("Cannot remove cache element with null key");
 }
 int storeIndex = getStoreIndex(key);
 
 Object lock = locks[storeIndex];
 ManagerUtil.monitorEnter(lock, writeLockLevel);
 try {
  ((TCMap) store[storeIndex]).__tc_remove_logical(key);
  ((TCMap) dtmStore[storeIndex]).__tc_remove_logical(key);
 } finally {
  ManagerUtil.monitorExit(lock, writeLockLevel);
 }
}

代码示例来源:origin: org.terracotta.modules/tim-ehcache-commons

public Object get(final Object key) {
 if(config.isLoggingEnabled()) {
  logger.info("Get [" + key + "]");
 }
 if(key == null) {
  Assert.fail("Cannot get cache element with null key");
 }
 Element e = null;
 e = findCacheDataUnlocked(key);
 if (e != null) {
  if (e.isExpired()) {
   missCountExpired++;
   return null;
  } else {
   hitCount++;
   updateTimestampIfNeeded(key, e);
  }
  return e;
 }
 missCountNotFound++;
 return null;
}

代码示例来源:origin: org.terracotta/terracotta-ee

@Override
public void handleEvent(final EventContext context) {
 final NodeID nodeId = ((TCMessage)context).getSourceNodeID();
 if (nodeId.getNodeType() == NodeID.CLIENT_NODE_TYPE) {
  final ClientID clientId = (ClientID)nodeId;
  if (context instanceof RegisterServerEventListenerMessage) {
   final RegisterServerEventListenerMessage msg = (RegisterServerEventListenerMessage)context;
   serverEventNotifier.register(clientId, msg.getDestination(), msg.getEventTypes());
   LOG.debug("Server event listener registration message from client [" + nodeId + "] has been received: " + context);
   LOG.debug("Destination: " + msg.getDestination() + ", event: " + msg.getEventTypes());
  } else if (context instanceof UnregisterServerEventListenerMessage) {
   final UnregisterServerEventListenerMessage msg = (UnregisterServerEventListenerMessage)context;
   serverEventNotifier.unregister(clientId, msg.getDestination());
  } else {
   Assert.fail("Unknown event type " + context.getClass().getName());
  }
 }
}

代码示例来源:origin: org.terracotta/terracotta-l1

response.send();
} else {
 Assert.fail("Unknown event type " + context.getClass().getName());

代码示例来源:origin: org.kill-bill.billing/killbill-beatrix

fail("Should fail to trigger dryRun invoice prior subscription starts");
} catch (final InvoiceApiException e) {
  assertEquals(e.getCode(), ErrorCode.INVOICE_NOTHING_TO_DO.getCode());

代码示例来源:origin: org.terracotta/terracotta-ee

Assert.fail("Unexpected message while in handshaking mode: " + msg);

代码示例来源:origin: org.terracotta/terracotta-l1

Assert.fail("Unexpected message while in handshaking mode: " + msg);

代码示例来源:origin: org.terracotta/terracotta-l1-ee

Assert.fail("Unexpected message while in handshaking mode: " + msg);

相关文章