本文整理了Java中com.tc.util.Assert
类的一些代码示例,展示了Assert
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Assert
类的具体详情如下:
包路径:com.tc.util.Assert
类名称:Assert
[英]A general purpose assertion utility. By default it is on, but you can disable the throwing of exceptions by giving the system property "tcassert" a value of 'false'.
[中]通用断言实用程序。默认情况下,它处于启用状态,但您可以通过将系统属性“tcassert”的值设置为“false”来禁用异常的引发。
代码示例来源:origin: org.terracotta/terracotta-ee
/**
* New id
*
* @param id ID value
*/
public StringLockID(final String id) {
Assert.eval(id != null);
this.id = id;
}
代码示例来源:origin: org.terracotta/terracotta-ee
public GroupObjectIDProviderImpl(ObjectCreationStrategy creationStrategy, Sequence[] sequences, GroupID[] grpIds) {
Assert.assertEquals(sequences.length, grpIds.length);
this.creationStrategy = creationStrategy;
for (int i = 0; i < grpIds.length; i++) {
this.gidToSequence.put(grpIds[i], sequences[i]);
this.cachedObjectIds.put(grpIds[i], new TreeSet<Long>());
}
}
代码示例来源:origin: org.terracotta/terracotta-ee
/**
* Construct new spec
*
* @param className Class name
*/
public DmiClassSpec(final String className) {
Assert.pre(className != null);
this.className = className;
}
代码示例来源:origin: org.terracotta/terracotta-ee
public ResourceConfigurationSource(String path, Class relativeTo) {
Assert.assertNotBlank(path);
Assert.assertNotNull(relativeTo);
this.path = path;
this.relativeTo = relativeTo;
}
代码示例来源:origin: org.terracotta/terracotta-ee
private void validateOldLock(ServerLock lock) {
if (oldLock != null) {
Assert.assertSame(oldLock, lock);
} else {
Assert.assertNull(lock);
}
}
代码示例来源:origin: org.terracotta/terracotta-ee
private static String getPropertyFromMethodName(String methodName) {
Assert.assertNotBlank(methodName);
Assert.eval(methodName.length() >= "get".length());
return methodName.substring("get".length(), "get".length() + 1).toLowerCase()
+ methodName.substring("get".length() + 1);
}
代码示例来源:origin: org.terracotta/terracotta-ee
private void addSpec(final TransparencyClassSpec spec) {
synchronized (specLock) {
Assert.eval(!classSpecs.containsKey(spec.getClassName()));
Assert.assertNotNull(spec);
classSpecs.put(spec.getClassName(), spec);
}
}
代码示例来源:origin: org.terracotta/terracotta-ee
@Override
public ServerLockContext setNext(ServerLockContext next) {
Assert.assertNull(next);
return null;
}
}
代码示例来源:origin: org.terracotta.toolkit/terracotta-toolkit-1.0-impl
private ConcurrentDistributedMapDso(final int lockLevel, final LockStrategy<? super K> lockStrategy) {
// ensure that DSO is active at construction time, ie. fail fast
Assert.pre(!(ManagerUtil.getManager() instanceof NullManager));
this.dsoLockType = lockLevel;
this.store = new SelectableConcurrentHashMap();
this.lockStrategy = lockStrategy;
this.localSize = new AtomicInteger(0);
Assert.post(this.store != null);
}
代码示例来源:origin: org.terracotta/terracotta-l1-ee
@Override
public SequenceID getSequenceID() {
Assert.assertFalse(this.seqID.isNull());
return this.seqID;
}
代码示例来源:origin: org.terracotta/terracotta-ee
@Override
public BatchSequenceReceiver getBatchReceiver(final BatchSequence[] sequences) {
Assert.assertTrue(sequences.length == 1);
return sequences[0];
}
代码示例来源:origin: org.terracotta.toolkit/terracotta-toolkit-1.3-impl
private static void verifyEventLevel() {
OperatorEventLevel operatorEventLevels[] = OperatorEventLevel.values();
Assert.assertEquals(coreEventLevelMap.size(), operatorEventLevels.length);
for (OperatorEventLevel operatorEventLevel : operatorEventLevels) {
Assert.assertTrue(coreEventLevelMap.keySet().contains(operatorEventLevel.name()));
}
}
代码示例来源:origin: org.terracotta/terracotta-ee
private void checkVariableHeaderEmpty() {
Assert.assertEquals(0, actionCount);
Assert.assertFalse(Conversion.getFlag(flags, DNA.HAS_PARENT_ID));
Assert.assertFalse(Conversion.getFlag(flags, DNA.HAS_ARRAY_LENGTH));
}
代码示例来源:origin: org.terracotta/terracotta-l1
@Override
public ServerEventListenerManager createServerEventListenerManager(final DSOClientMessageChannel dsoChannel,
final TaskRunner runner) {
final GroupID[] defaultGroups = dsoChannel.getGroupIDs();
Assert.assertNotNull(defaultGroups);
Assert.assertEquals(1, defaultGroups.length);
return new ServerEventListenerManagerImpl(runner);
}
}
代码示例来源:origin: org.terracotta/terracotta-ee
synchronized void initiateIndexSync() throws IOException {
Assert.assertTrue(this.state == SYNC_STARTED);
Assert.assertNull(currentSyncFile);
nextSyncFile();
sendData();
}
代码示例来源:origin: org.terracotta/terracotta-ee
private State moveToWaiter(State oldState) {
Assert.assertNotNull(oldState);
Assert.assertTrue(oldState.getType() == Type.HOLDER);
Assert.assertTrue(oldState.getLockLevel() == ServerLockLevel.WRITE);
switch (oldState.getLockLevel()) {
case WRITE:
return State.WAITER;
default:
// should never come here
throw new IllegalStateException("Should never come here");
}
}
代码示例来源: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
public ElementReturn(SchemaParticle particle, boolean isOptional) {
Assert.assertNotNull(particle);
this.particle = particle;
this.isOptional = isOptional;
}
代码示例来源:origin: org.terracotta/terracotta-l1
@Override
public void receiveMessage(OOOProtocolMessage msg) {
Assert.assertNotNull("Receive layer is null.", this.receiveLayer);
Assert.assertNotNull("Attempt to null msg", msg);
Assert.eval(msg.isSend());
this.receiveLayer.receive(msg.getPayload());
}
代码示例来源:origin: org.terracotta/terracotta-ee
/**
* If o is non-null, throw assertion error
*
* @param o Object
*/
public static void assertNull(Object o) {
assertNull("object", o);
}
内容来源于网络,如有侵权,请联系作者删除!