Here are the examples of the java api org.springframework.util.Assert.isTrue() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
1427 Examples
19
View Source File : CachedUidGenerator.java
License : Apache License 2.0
Project Creator : zuihou
License : Apache License 2.0
Project Creator : zuihou
/**
* Setters for spring property
*/
public void setBoostPower(final int boostPower) {
replacedert.isTrue(boostPower > 0, "Boost power must be positive!");
this.boostPower = boostPower;
}
19
View Source File : RingBuffer.java
License : Apache License 2.0
Project Creator : zuihou
License : Apache License 2.0
Project Creator : zuihou
/**
* Take an UID of the ring at the next cursor, this is a lock free operation by using atomic cursor<p>
* <p>
* Before getting the UID, we also check whether reach the padding threshold,
* the padding buffer operation will be triggered in another thread<br>
* If there is no more available UID to be taken, the specified {@link RejectedTakeBufferHandler} will be applied<br>
*
* @return UID
* @throws IllegalStateException if the cursor moved back
*/
public long take() {
// spin get next available cursor
long currentCursor = cursor.get();
long nextCursor = cursor.updateAndGet(old -> old == tail.get() ? old : old + 1);
// check for safety consideration, it never occurs
replacedert.isTrue(nextCursor >= currentCursor, "Curosr can't move back");
// trigger padding in an async-mode if reach the threshold
long currentTail = tail.get();
if (currentTail - nextCursor < paddingThreshold) {
LOGGER.info("Reach the padding threshold:{}. tail:{}, cursor:{}, rest:{}", paddingThreshold, currentTail, nextCursor, currentTail - nextCursor);
bufferPaddingExecutor.asyncPadding();
}
// cursor catch the tail, means that there is no more available UID to take
if (nextCursor == currentCursor) {
rejectedTakeHandler.rejectTakeBuffer(this);
}
// 1. check next slot flag is CAN_TAKE_FLAG
int nextCursorIndex = calSlotIndex(nextCursor);
replacedert.isTrue(flags[nextCursorIndex].get() == CAN_TAKE_FLAG, "Curosr not in can take status");
// 2. get UID from next slot
// 3. set next slot flag as CAN_PUT_FLAG.
long uid = slots[nextCursorIndex];
flags[nextCursorIndex].set(CAN_PUT_FLAG);
// Note that: Step 2,3 can not swap. If we set flag before get value of slot, the producer may overwrite the
// slot with a new UID, and this may cause the consumer take the UID twice after walk a round the ring
return uid;
}
19
View Source File : BufferPaddingExecutor.java
License : Apache License 2.0
Project Creator : zuihou
License : Apache License 2.0
Project Creator : zuihou
/**
* Setters
*/
public void setScheduleInterval(final long scheduleInterval) {
replacedert.isTrue(scheduleInterval > 0, "Schedule interval must positive!");
this.scheduleInterval = scheduleInterval;
}
19
View Source File : ConsistentHashAlgorithm.java
License : Apache License 2.0
Project Creator : zilongTong
License : Apache License 2.0
Project Creator : zilongTong
/**
* 创建新的虚拟节点列表
*
* @param servers
* @return
*/
public static SortedMap<Integer, String> newVirtualNodes(@NonNull List<String> servers, int vNodeNum) {
replacedert.isTrue(vNodeNum > 0, "number of virtual nodes should be positive");
SortedMap<Integer, String> vNodes = new TreeMap<>();
servers.forEach(str -> {
for (int i = 0; i < vNodeNum; i++) {
String virtualNodeName = str + "&&VN" + i;
int hash = getHash(virtualNodeName);
// System.out.println("虚拟节点[" + virtualNodeName + "]被添加, hash值为" + hash);
vNodes.put(hash, virtualNodeName);
}
});
return vNodes;
}
19
View Source File : RedisFrequencyLimiter.java
License : MIT License
Project Creator : zidoshare
License : MIT License
Project Creator : zidoshare
@Override
public long tryGet(String key, long timeout) {
replacedert.isTrue(timeout > 1, "超时时间设定以秒为单位,并且需要大于一秒");
replacedert.isTrue(timeout <= Integer.MAX_VALUE, "超时时间需要小于等于" + Integer.MAX_VALUE);
long now = SystemClock.now();
now = now / 1000;
String prefixedKey = prefix + key;
Long expire = template.getExpire(prefixedKey, TimeUnit.MILLISECONDS);
// redis集群可能无法准确过期,用ttl判断更准确
if (expire != null) {
// 如果值永久有效将永远无法有效获取
if (expire == -1) {
throw new IllegalStateException(String.format("键[%s]永久有效,需要排查", prefixedKey));
}
if (expire > 0) {
return expire;
}
}
createTag(key, now, timeout);
return 0;
}
19
View Source File : ReflectionUtils.java
License : MIT License
Project Creator : zidoshare
License : MIT License
Project Creator : zidoshare
/**
* Gets parameterized type.
*
* @param interfaceType interface type must not be null
* @param implementationClreplaced implementation clreplaced of the interface must not be null
* @return parameterized type of the interface or null if it is mismatch
*/
@Nullable
public static ParameterizedType getParameterizedType(@NonNull Clreplaced<?> interfaceType, Clreplaced<?> implementationClreplaced) {
replacedert.notNull(interfaceType, "Interface type must not be null");
replacedert.isTrue(interfaceType.isInterface(), "The give type must be an interface");
if (implementationClreplaced == null) {
// If the super clreplaced is Object parent then return null
return null;
}
// Get parameterized type
ParameterizedType currentType = getParameterizedType(interfaceType, implementationClreplaced.getGenericInterfaces());
if (currentType != null) {
// return the current type
return currentType;
}
Clreplaced<?> superclreplaced = implementationClreplaced.getSuperclreplaced();
return getParameterizedType(interfaceType, superclreplaced);
}
19
View Source File : ProcessorParser.java
License : Apache License 2.0
Project Creator : zhongxunking
License : Apache License 2.0
Project Creator : zhongxunking
// 解析出@ProcessorExecute方法
private static Method parseToExecuteMethod(Clreplaced<?> processorClreplaced) {
for (Method method : processorClreplaced.getDeclaredMethods()) {
if (AnnotatedElementUtils.findMergedAnnotation(method, ProcessorExecute.clreplaced) == null) {
continue;
}
// 校验方法类型
replacedert.isTrue(Modifier.isPublic(method.getModifiers()), String.format("@ProcessorExecute方法[%s]必须是public类型", method));
// 校验入参类型
Clreplaced<?>[] parameterTypes = method.getParameterTypes();
if (parameterTypes.length != 1 || parameterTypes[0] != FlowContext.clreplaced) {
throw new IllegalArgumentException(String.format("@ProcessorExecute方法[%s]的入参必须是(FlowContext<T> context)", method));
}
return method;
}
throw new IllegalArgumentException(String.format("处理器[%s]不存在@ProcessorExecute方法", processorClreplaced));
}
19
View Source File : TheFlowMapperParser.java
License : Apache License 2.0
Project Creator : zhongxunking
License : Apache License 2.0
Project Creator : zhongxunking
// 解析出@MappingNode方法
private static Method parseToMappingNodeMethod(Clreplaced<?> theFlowMapperClreplaced) {
for (Method method : theFlowMapperClreplaced.getDeclaredMethods()) {
if (AnnotatedElementUtils.findMergedAnnotation(method, MappingNode.clreplaced) == null) {
continue;
}
// 校验方法类型、返回类型
replacedert.isTrue(Modifier.isPublic(method.getModifiers()), String.format("@MappingNode方法[%s]必须是public类型", method));
replacedert.isTrue(method.getReturnType() == String.clreplaced, String.format("@MappingNode方法[%s]返回类型必须是String", method));
// 校验入参类型
Clreplaced<?>[] parameterTypes = method.getParameterTypes();
if (parameterTypes.length != 1 || parameterTypes[0] != FlowContext.clreplaced) {
throw new IllegalArgumentException(String.format("@ProcessorExecute方法[%s]的入参必须是(FlowContext<T> context)", method));
}
return method;
}
throw new IllegalArgumentException(String.format("特定流程映射器[%s]不存在@MappingNode法", theFlowMapperClreplaced));
}
19
View Source File : ClassListenResolver.java
License : Apache License 2.0
Project Creator : zhongxunking
License : Apache License 2.0
Project Creator : zhongxunking
@Override
public void init(Method listenMethod) {
// 校验入参
Clreplaced[] parameterTypes = listenMethod.getParameterTypes();
replacedert.isTrue(parameterTypes.length == 1, String.format("监听方法[%s]必须只有一个入参", listenMethod));
// 设置事件类型
eventType = parameterTypes[0];
}
19
View Source File : EnhanceConcurrentControlAuthenticationStrategy.java
License : MIT License
Project Creator : ZeroOrInfinity
License : MIT License
Project Creator : ZeroOrInfinity
/**
* Sets the <tt>maxSessions</tt> property. The default value is 1. Use -1 for
* unlimited sessions.
*
* @param maximumSessions the maximimum number of permitted sessions a user can have
* open simultaneously.
*/
@Override
public void setMaximumSessions(int maximumSessions) {
replacedert.isTrue(maximumSessions != 0, "MaximumLogins must be either -1 to allow unlimited logins, or a positive integer to specify a maximum");
super.setMaximumSessions(maximumSessions);
this.maximumSessions = maximumSessions;
}
19
View Source File : CommonResult.java
License : MIT License
Project Creator : YunaiV
License : MIT License
Project Creator : YunaiV
public static <T> CommonResult<T> error(Integer code, String message) {
replacedert.isTrue(!GlobalErrorCodeConstants.SUCCESS.getCode().equals(code), "code 必须是错误的!");
CommonResult<T> result = new CommonResult<>();
result.code = code;
result.msg = message;
return result;
}
19
View Source File : HttpTunnelServer.java
License : Apache License 2.0
Project Creator : yuanmabiji
License : Apache License 2.0
Project Creator : yuanmabiji
/**
* Set the long poll timeout for the server.
* @param longPollTimeout the long poll timeout in milliseconds
*/
public void setLongPollTimeout(int longPollTimeout) {
replacedert.isTrue(longPollTimeout > 0, "LongPollTimeout must be a positive value");
this.longPollTimeout = longPollTimeout;
}
19
View Source File : HttpTunnelServer.java
License : Apache License 2.0
Project Creator : yuanmabiji
License : Apache License 2.0
Project Creator : yuanmabiji
/**
* Set the maximum amount of time to wait for a client before closing the connection.
* @param disconnectTimeout the disconnect timeout in milliseconds
*/
public void setDisconnectTimeout(long disconnectTimeout) {
replacedert.isTrue(disconnectTimeout > 0, "DisconnectTimeout must be a positive value");
this.disconnectTimeout = disconnectTimeout;
}
19
View Source File : FileSystemWatcher.java
License : Apache License 2.0
Project Creator : yuanmabiji
License : Apache License 2.0
Project Creator : yuanmabiji
/**
* Add a source folder to monitor. Cannot be called after the watcher has been
* {@link #start() started}.
* @param folder the folder to monitor
*/
public void addSourceFolder(File folder) {
replacedert.notNull(folder, "Folder must not be null");
replacedert.isTrue(!folder.isFile(), "Folder '" + folder + "' must not be a file");
synchronized (this.monitor) {
checkNotStarted();
this.folders.put(folder, null);
}
}
19
View Source File : WebServicesProperties.java
License : Apache License 2.0
Project Creator : yuanmabiji
License : Apache License 2.0
Project Creator : yuanmabiji
public void setPath(String path) {
replacedert.notNull(path, "Path must not be null");
replacedert.isTrue(path.length() > 1, "Path must have length greater than 1");
replacedert.isTrue(path.startsWith("/"), "Path must start with '/'");
this.path = path;
}
19
View Source File : HazelcastProperties.java
License : Apache License 2.0
Project Creator : yuanmabiji
License : Apache License 2.0
Project Creator : yuanmabiji
/**
* Resolve the config location if set.
* @return the location or {@code null} if it is not set
* @throws IllegalArgumentException if the config attribute is set to an unknown
* location
*/
public Resource resolveConfigLocation() {
if (this.config == null) {
return null;
}
replacedert.isTrue(this.config.exists(), () -> "Hazelcast configuration does not " + "exist '" + this.config.getDescription() + "'");
return this.config;
}
19
View Source File : BeanTypeRegistry.java
License : Apache License 2.0
Project Creator : yuanmabiji
License : Apache License 2.0
Project Creator : yuanmabiji
/**
* Factory method to get the {@link BeanTypeRegistry} for a given {@link BeanFactory}.
* @param beanFactory the source bean factory
* @return the {@link BeanTypeRegistry} for the given bean factory
*/
static BeanTypeRegistry get(ListableBeanFactory beanFactory) {
replacedert.isInstanceOf(DefaultListableBeanFactory.clreplaced, beanFactory);
DefaultListableBeanFactory listableBeanFactory = (DefaultListableBeanFactory) beanFactory;
replacedert.isTrue(listableBeanFactory.isAllowEagerClreplacedLoading(), "Bean factory must allow eager clreplaced loading");
if (!listableBeanFactory.containsLocalBean(BEAN_NAME)) {
BeanDefinition definition = BeanDefinitionBuilder.genericBeanDefinition(BeanTypeRegistry.clreplaced, () -> new BeanTypeRegistry((DefaultListableBeanFactory) beanFactory)).getBeanDefinition();
listableBeanFactory.registerBeanDefinition(BEAN_NAME, definition);
}
return listableBeanFactory.getBean(BEAN_NAME, BeanTypeRegistry.clreplaced);
}
19
View Source File : DiskSpaceHealthIndicatorProperties.java
License : Apache License 2.0
Project Creator : yuanmabiji
License : Apache License 2.0
Project Creator : yuanmabiji
public void setThreshold(DataSize threshold) {
replacedert.isTrue(!threshold.isNegative(), "threshold must be greater than or equal to 0");
this.threshold = threshold;
}
19
View Source File : DiskSpaceHealthIndicatorProperties.java
License : Apache License 2.0
Project Creator : yuanmabiji
License : Apache License 2.0
Project Creator : yuanmabiji
public void setPath(File path) {
replacedert.isTrue(path.exists(), () -> "Path '" + path + "' does not exist");
replacedert.isTrue(path.canRead(), () -> "Path '" + path + "' cannot be read");
this.path = path;
}
19
View Source File : WebEndpointProperties.java
License : Apache License 2.0
Project Creator : yuanmabiji
License : Apache License 2.0
Project Creator : yuanmabiji
public void setBasePath(String basePath) {
replacedert.isTrue(basePath.isEmpty() || basePath.startsWith("/"), "Base path must start with '/' or be empty");
this.basePath = cleanBasePath(basePath);
}
19
View Source File : EndpointServlet.java
License : Apache License 2.0
Project Creator : yuanmabiji
License : Apache License 2.0
Project Creator : yuanmabiji
public EndpointServlet withInitParameters(Map<String, String> initParameters) {
replacedert.notNull(initParameters, "InitParameters must not be null");
boolean hasEmptyName = initParameters.keySet().stream().anyMatch((name) -> !StringUtils.hasText(name));
replacedert.isTrue(!hasEmptyName, "InitParameters must not contain empty names");
Map<String, String> mergedInitParameters = new LinkedHashMap<>(this.initParameters);
mergedInitParameters.putAll(initParameters);
return new EndpointServlet(this.servlet, mergedInitParameters);
}
19
View Source File : ServletListenerRegistrationBean.java
License : Apache License 2.0
Project Creator : yuanmabiji
License : Apache License 2.0
Project Creator : yuanmabiji
/**
* Set the listener that will be registered.
* @param listener the listener to register
*/
public void setListener(T listener) {
replacedert.notNull(listener, "Listener must not be null");
replacedert.isTrue(isSupportedType(listener), "Listener is not of a supported type");
this.listener = listener;
}
19
View Source File : ConfigurationPropertyName.java
License : Apache License 2.0
Project Creator : yuanmabiji
License : Apache License 2.0
Project Creator : yuanmabiji
/**
* Return a {@link ConfigurationPropertyName} for the specified string.
* @param name the source name
* @param returnNullIfInvalid if null should be returned if the name is not valid
* @return a {@link ConfigurationPropertyName} instance
* @throws InvalidConfigurationPropertyNameException if the name is not valid and
* {@code returnNullIfInvalid} is {@code false}
*/
static ConfigurationPropertyName of(CharSequence name, boolean returnNullIfInvalid) {
if (name == null) {
replacedert.isTrue(returnNullIfInvalid, "Name must not be null");
return null;
}
if (name.length() == 0) {
return EMPTY;
}
if (name.charAt(0) == '.' || name.charAt(name.length() - 1) == '.') {
if (returnNullIfInvalid) {
return null;
}
throw new InvalidConfigurationPropertyNameException(name, Collections.singletonList('.'));
}
Elements elements = new ElementsParser(name, '.').parse();
for (int i = 0; i < elements.getSize(); i++) {
if (elements.getType(i) == ElementType.NON_UNIFORM) {
if (returnNullIfInvalid) {
return null;
}
throw new InvalidConfigurationPropertyNameException(name, getInvalidChars(elements, i));
}
}
return new ConfigurationPropertyName(elements);
}
19
View Source File : AdvertiseController.java
License : Apache License 2.0
Project Creator : xunibidev
License : Apache License 2.0
Project Creator : xunibidev
private void checkAmount(AdvertiseType advertiseType, Advertise advertise, OtcCoin otcCoin, Member member) {
if (advertiseType.equals(AdvertiseType.SELL)) {
replacedert.isTrue(compare(advertise.getNumber(), otcCoin.getSellMinAmount()), msService.getMessage("SELL_NUMBER_MIN") + otcCoin.getSellMinAmount());
MemberWallet memberWallet = memberWalletService.findByOtcCoinAndMemberId(otcCoin, member.getId());
replacedert.isTrue(compare(memberWallet.getBalance(), advertise.getNumber()), msService.getMessage("INSUFFICIENT_BALANCE"));
} else {
replacedert.isTrue(compare(advertise.getNumber(), otcCoin.getBuyMinAmount()), msService.getMessage("BUY_NUMBER_MIN") + otcCoin.getBuyMinAmount());
}
}
19
View Source File : AdvertiseController.java
License : Apache License 2.0
Project Creator : xunibidev
License : Apache License 2.0
Project Creator : xunibidev
private StringBuffer checkPayMode(String[] pay, AdvertiseType advertiseType, Member member) {
StringBuffer payMode = new StringBuffer();
Arrays.stream(pay).forEach(x -> {
if (advertiseType.equals(AdvertiseType.SELL)) {
if (ALI.getCnName().equals(x)) {
replacedert.isTrue(member.getAlipay() != null, msService.getMessage("NO_ALI"));
} else if (WECHAT.getCnName().equals(x)) {
replacedert.isTrue(member.getWechatPay() != null, msService.getMessage("NO_WECHAT"));
} else if (BANK.getCnName().equals(x)) {
replacedert.isTrue(member.getBankInfo() != null, msService.getMessage("NO_BANK"));
} else {
throw new IllegalArgumentException("pay parameter error");
}
}
payMode.append(x + ",");
});
return payMode.deleteCharAt(payMode.length() - 1);
}
19
View Source File : CachedUidGenerator.java
License : MIT License
Project Creator : xk11961677
License : MIT License
Project Creator : xk11961677
/**
* Setters for spring property
*/
public void setBoostPower(int boostPower) {
replacedert.isTrue(boostPower > 0, "Boost power must be positive!");
this.boostPower = boostPower;
}
19
View Source File : CachedUidGenerator.java
License : MIT License
Project Creator : xk11961677
License : MIT License
Project Creator : xk11961677
public void setScheduleInterval(long scheduleInterval) {
replacedert.isTrue(scheduleInterval > 0, "Schedule interval must positive!");
this.scheduleInterval = scheduleInterval;
}
19
View Source File : RingBuffer.java
License : MIT License
Project Creator : xk11961677
License : MIT License
Project Creator : xk11961677
/**
* Take an UID of the ring at the next cursor, this is a lock free operation by using atomic cursor<p>
*
* Before getting the UID, we also check whether reach the padding threshold,
* the padding buffer operation will be triggered in another thread<br>
* If there is no more available UID to be taken, the specified {@link RejectedTakeBufferHandler} will be applied<br>
*
* @return UID
* @throws IllegalStateException if the cursor moved back
*/
public long take() {
// spin get next available cursor
long currentCursor = cursor.get();
long nextCursor = cursor.updateAndGet(old -> old == tail.get() ? old : old + 1);
// check for safety consideration, it never occurs
replacedert.isTrue(nextCursor >= currentCursor, "Curosr can't move back");
// trigger padding in an async-mode if reach the threshold
long currentTail = tail.get();
if (currentTail - nextCursor < paddingThreshold) {
LOGGER.info("Reach the padding threshold:{}. tail:{}, cursor:{}, rest:{}", paddingThreshold, currentTail, nextCursor, currentTail - nextCursor);
bufferPaddingExecutor.asyncPadding();
}
// cursor catch the tail, means that there is no more available UID to take
if (nextCursor == currentCursor) {
rejectedTakeHandler.rejectTakeBuffer(this);
}
// 1. check next slot flag is CAN_TAKE_FLAG
int nextCursorIndex = calSlotIndex(nextCursor);
replacedert.isTrue(flags[nextCursorIndex].get() == CAN_TAKE_FLAG, "Curosr not in can take status");
// 2. get UID from next slot
// 3. set next slot flag as CAN_PUT_FLAG.
long uid = slots[nextCursorIndex];
flags[nextCursorIndex].set(CAN_PUT_FLAG);
// Note that: Step 2,3 can not swap. If we set flag before get value of slot, the producer may overwrite the
// slot with a new UID, and this may cause the consumer take the UID twice after walk a round the ring
return uid;
}
19
View Source File : BufferPaddingExecutor.java
License : MIT License
Project Creator : xk11961677
License : MIT License
Project Creator : xk11961677
/**
* Setters
*/
public void setScheduleInterval(long scheduleInterval) {
replacedert.isTrue(scheduleInterval > 0, "Schedule interval must positive!");
this.scheduleInterval = scheduleInterval;
}
19
View Source File : AttestationOptionsProviderImpl.java
License : Apache License 2.0
Project Creator : webauthn4j
License : Apache License 2.0
Project Creator : webauthn4j
public void setRegistrationTimeout(Long registrationTimeout) {
replacedert.notNull(registrationTimeout, "registrationTimeout must not be null.");
replacedert.isTrue(registrationTimeout >= 0, "registrationTimeout must be within unsigned long.");
this.registrationTimeout = registrationTimeout;
}
19
View Source File : AssertionOptionsProviderImpl.java
License : Apache License 2.0
Project Creator : webauthn4j
License : Apache License 2.0
Project Creator : webauthn4j
public void setAuthenticationTimeout(Long authenticationTimeout) {
replacedert.notNull(authenticationTimeout, "authenticationTimeout must not be null.");
replacedert.isTrue(authenticationTimeout >= 0, "registrationTimeout must be within unsigned long.");
this.authenticationTimeout = authenticationTimeout;
}
19
View Source File : PageInfo.java
License : Apache License 2.0
Project Creator : WeBankFinTech
License : Apache License 2.0
Project Creator : WeBankFinTech
public void setTotalPage(int totalPage) {
replacedert.isTrue(pageSize >= 0, "total page must be larger than or equals to 0");
this.totalPage = totalPage;
}
19
View Source File : PageInfo.java
License : Apache License 2.0
Project Creator : WeBankFinTech
License : Apache License 2.0
Project Creator : WeBankFinTech
public void setTotalCount(int totalCount) {
replacedert.isTrue(pageSize >= 0, "total count must be larger than or equals to 0");
this.totalCount = totalCount;
}
19
View Source File : PageInfo.java
License : Apache License 2.0
Project Creator : WeBankFinTech
License : Apache License 2.0
Project Creator : WeBankFinTech
public void setCurrentPage(int currentPage) {
replacedert.isTrue(pageSize >= 1, "current page must be larger than 1");
this.currentPage = currentPage;
}
19
View Source File : PageInfo.java
License : Apache License 2.0
Project Creator : WeBankFinTech
License : Apache License 2.0
Project Creator : WeBankFinTech
public void setPageSize(int pageSize) {
replacedert.isTrue(pageSize >= 1, "page size must be larger than 1");
this.pageSize = pageSize;
}
19
View Source File : AbstractEmailProcessor.java
License : Apache License 2.0
Project Creator : wangrenlei
License : Apache License 2.0
Project Creator : wangrenlei
/**
* Fills the internal message queue if such queue is empty. This is due to
* the fact that per single session there may be multiple messages retrieved
* from the email server (see FETCH_SIZE).
*/
private synchronized void fillMessageQueueIfNecessary() {
if (this.messageQueue.isEmpty()) {
Object[] messages;
try {
messages = this.messageReceiver.receive();
} catch (MessagingException e) {
String errorMsg = "Failed to receive messages from Email server: [" + e.getClreplaced().getName() + " - " + e.getMessage();
this.getLogger().error(errorMsg);
throw new ProcessException(errorMsg, e);
}
if (messages != null) {
for (Object message : messages) {
replacedert.isTrue(message instanceof Message, "Message is not an instance of javax.mail.Message");
this.messageQueue.offer((Message) message);
}
}
}
}
19
View Source File : SockJsWebSocketHandler.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Override
public void afterConnectionEstablished(WebSocketSession wsSession) throws Exception {
replacedert.isTrue(this.sessionCount.compareAndSet(0, 1), "Unexpected connection");
this.sockJsSession.initializeDelegateSession(wsSession);
}
19
View Source File : SubProtocolWebSocketHandler.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Override
public final void start() {
replacedert.isTrue(this.defaultProtocolHandler != null || !this.protocolHandlers.isEmpty(), "No handlers");
synchronized (this.lifecycleMonitor) {
this.clientOutboundChannel.subscribe(this);
this.running = true;
}
}
19
View Source File : CompositeRequestCondition.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
private void replacedertNumberOfConditions(CompositeRequestCondition other) {
replacedert.isTrue(getLength() == other.getLength(), "Cannot combine CompositeRequestConditions with a different number of conditions. " + ObjectUtils.nullSafeToString(this.requestConditions) + " and " + ObjectUtils.nullSafeToString(other.requestConditions));
}
19
View Source File : MockServletContext.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Override
public RequestDispatcher getRequestDispatcher(String path) {
replacedert.isTrue(path.startsWith("/"), () -> "RequestDispatcher path [" + path + "] at ServletContext level must start with '/'");
return new MockRequestDispatcher(path);
}
19
View Source File : MockHttpServletRequest.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
/**
* The implementation of this (Servlet 3.1+) method calls
* {@link MockHttpSession#changeSessionId()} if the session is a mock session.
* Otherwise it simply returns the current session id.
* @since 4.0.3
*/
public String changeSessionId() {
replacedert.isTrue(this.session != null, "The request does not have a session");
if (this.session instanceof MockHttpSession) {
return ((MockHttpSession) this.session).changeSessionId();
}
return this.session.getId();
}
19
View Source File : MockCookie.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
private static String extractAttributeValue(String attribute, String header) {
String[] nameAndValue = attribute.split("=");
replacedert.isTrue(nameAndValue.length == 2, () -> "No value in attribute '" + nameAndValue[0] + "' for Set-Cookie header '" + header + "'");
return nameAndValue[1];
}
19
View Source File : MockCookie.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
/**
* Factory method that parses the value of a "Set-Cookie" header.
* @param setCookieHeader the "Set-Cookie" value; never {@code null} or empty
* @return the created cookie
*/
public static MockCookie parse(String setCookieHeader) {
replacedert.notNull(setCookieHeader, "Set-Cookie header must not be null");
String[] cookieParts = setCookieHeader.split("\\s*=\\s*", 2);
replacedert.isTrue(cookieParts.length == 2, () -> "Invalid Set-Cookie header '" + setCookieHeader + "'");
String name = cookieParts[0];
String[] valueAndAttributes = cookieParts[1].split("\\s*;\\s*", 2);
String value = valueAndAttributes[0];
String[] attributes = (valueAndAttributes.length > 1 ? valueAndAttributes[1].split("\\s*;\\s*") : new String[0]);
MockCookie cookie = new MockCookie(name, value);
for (String attribute : attributes) {
if (StringUtils.startsWithIgnoreCase(attribute, "Domain")) {
cookie.setDomain(extractAttributeValue(attribute, setCookieHeader));
} else if (StringUtils.startsWithIgnoreCase(attribute, "Max-Age")) {
cookie.setMaxAge(Integer.parseInt(extractAttributeValue(attribute, setCookieHeader)));
} else if (StringUtils.startsWithIgnoreCase(attribute, "Path")) {
cookie.setPath(extractAttributeValue(attribute, setCookieHeader));
} else if (StringUtils.startsWithIgnoreCase(attribute, "Secure")) {
cookie.setSecure(true);
} else if (StringUtils.startsWithIgnoreCase(attribute, "HttpOnly")) {
cookie.setHttpOnly(true);
} else if (StringUtils.startsWithIgnoreCase(attribute, "SameSite")) {
cookie.setSameSite(extractAttributeValue(attribute, setCookieHeader));
}
}
return cookie;
}
19
View Source File : AbstractHttpServer.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
// InitializingBean
@Override
public final void afterPropertiesSet() throws Exception {
replacedert.notNull(this.host, "Host must not be null");
replacedert.isTrue(this.port >= 0, "Port must not be a negative number");
replacedert.isTrue(this.httpHandler != null || this.handlerMap != null, "No HttpHandler configured");
replacedert.state(!this.running, "Cannot reconfigure while running");
synchronized (this.lifecycleMonitor) {
initServer();
}
}
19
View Source File : UriComponentsBuilder.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
/**
* Set the URI port. Preplaceding {@code -1} will clear the port of this builder.
* @param port the URI port
* @return this UriComponentsBuilder
*/
@Override
public UriComponentsBuilder port(int port) {
replacedert.isTrue(port >= -1, "Port must be >= -1");
this.port = String.valueOf(port);
resetSchemeSpecificPart();
return this;
}
19
View Source File : AbstractRequestLoggingFilter.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
/**
* Set the maximum length of the payload body to be included in the log message.
* Default is 50 characters.
* @since 3.0
*/
public void setMaxPayloadLength(int maxPayloadLength) {
replacedert.isTrue(maxPayloadLength >= 0, "'maxPayloadLength' should be larger than or equal to 0");
this.maxPayloadLength = maxPayloadLength;
}
19
View Source File : CorsUtils.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
/**
* Check if the request is a same-origin one, based on {@code Origin}, and
* {@code Host} headers.
*
* <p><strong>Note:</strong> as of 5.1 this method ignores
* {@code "Forwarded"} and {@code "X-Forwarded-*"} headers that specify the
* client-originated address. Consider using the {@code ForwardedHeaderFilter}
* to extract and use, or to discard such headers.
*
* @return {@code true} if the request is a same-origin one, {@code false} in case
* of a cross-origin request
* @deprecated as of 5.2, same-origin checks are performed directly by {@link #isCorsRequest}
*/
@Deprecated
public static boolean isSameOrigin(ServerHttpRequest request) {
String origin = request.getHeaders().getOrigin();
if (origin == null) {
return true;
}
URI uri = request.getURI();
String actualScheme = uri.getScheme();
String actualHost = uri.getHost();
int actualPort = getPort(uri.getScheme(), uri.getPort());
replacedert.notNull(actualScheme, "Actual request scheme must not be null");
replacedert.notNull(actualHost, "Actual request host must not be null");
replacedert.isTrue(actualPort != -1, "Actual request port must not be undefined");
UriComponents originUrl = UriComponentsBuilder.fromOriginHeader(origin).build();
return (actualScheme.equals(originUrl.getScheme()) && actualHost.equals(originUrl.getHost()) && actualPort == getPort(originUrl.getScheme(), originUrl.getPort()));
}
19
View Source File : JaxWsPortClientInterceptor.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
/**
* Set the interface of the service that this factory should create a proxy for.
*/
public void setServiceInterface(@Nullable Clreplaced<?> serviceInterface) {
if (serviceInterface != null) {
replacedert.isTrue(serviceInterface.isInterface(), "'serviceInterface' must be an interface");
}
this.serviceInterface = serviceInterface;
}
19
View Source File : HttpComponentsHttpInvokerRequestExecutor.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
/**
* Set the connection timeout for the underlying HttpClient.
* A timeout value of 0 specifies an infinite timeout.
* <p>Additional properties can be configured by specifying a
* {@link RequestConfig} instance on a custom {@link HttpClient}.
* @param timeout the timeout value in milliseconds
* @see RequestConfig#getConnectTimeout()
*/
public void setConnectTimeout(int timeout) {
replacedert.isTrue(timeout >= 0, "Timeout must be a non-negative value");
this.requestConfig = cloneRequestConfig().setConnectTimeout(timeout).build();
}
19
View Source File : HttpComponentsHttpInvokerRequestExecutor.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
/**
* Set the socket read timeout for the underlying HttpClient.
* A timeout value of 0 specifies an infinite timeout.
* <p>Additional properties can be configured by specifying a
* {@link RequestConfig} instance on a custom {@link HttpClient}.
* @param timeout the timeout value in milliseconds
* @see #DEFAULT_READ_TIMEOUT_MILLISECONDS
* @see RequestConfig#getSocketTimeout()
*/
public void setReadTimeout(int timeout) {
replacedert.isTrue(timeout >= 0, "Timeout must be a non-negative value");
this.requestConfig = cloneRequestConfig().setSocketTimeout(timeout).build();
}
See More Examples