邯郸大名网站建设wordpress栏目使用不同的模板

张小明 2026/1/9 16:30:46
邯郸大名网站建设,wordpress栏目使用不同的模板,中国建设部网站四库平台,广州企业网络营销全网推广1.什么是awaitility #xff1f;Awaitility 是一个用于 Java 的小型领域特定语言#xff08;DSL#xff09;#xff0c;主要用于简化和管理异步操作的同步问题。它的主要作用包括#xff1a;等待异步操作完成#xff1a;在测试异步代码时#xff0c;Awaitility 可以帮助…1.什么是awaitility Awaitility 是一个用于 Java 的小型领域特定语言DSL主要用于简化和管理异步操作的同步问题。它的主要作用包括等待异步操作完成在测试异步代码时Awaitility 可以帮助你等待某个条件变为真而不需要使用复杂的线程管理或轮询机制。提高测试的可读性通过使用流畅的 APIAwaitility 使得测试代码更易于阅读和理解。减少测试中的线程问题避免在测试中显式地使用Thread.sleep()从而减少不必要的等待时间和线程问题。灵活的超时和轮询间隔允许你设置自定义的超时时间和轮询间隔以便更好地控制等待条件的检查频率。总之Awaitility 使得在测试异步操作时更加简单和直观特别是在需要等待某个条件满足的情况下。2.代码工程实验目的一个使用 Awaitility 的简单示例演示如何等待异步操作完成。假设我们有一个异步任务该任务在后台线程中更新一个标志我们希望在测试中等待这个标志变为truepom.xml?xml version1.0 encodingUTF-8?project xmlnshttp://maven.apache.org/POM/4.0.0xmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsdparentartifactIdJava-demo/artifactIdgroupIdcom.et/groupIdversion1.0-SNAPSHOT/version/parentmodelVersion4.0.0/modelVersionartifactIdAwaitility/artifactIdpropertiesmaven.compiler.source17/maven.compiler.sourcemaven.compiler.target17/maven.compiler.target/propertiesdependencies!-- Awaitility dependency --dependencygroupIdorg.awaitility/groupIdartifactIdawaitility/artifactIdversion4.2.0/version/dependency!-- JUnit dependency for testing --dependencygroupIdorg.junit.jupiter/groupIdartifactIdjunit-jupiter/artifactIdversion5.8.2/versionscopetest/scope/dependency/dependencies/projectAwaitilityExample异步任务startAsyncTask方法启动一个异步任务该任务在 5秒后将flag设置为true。Awaitility 使用在main方法中我们使用 Awaitility 的await()方法来等待flag变为true。我们设置了一个最大等待时间为 5 秒。条件检查until(example::isFlag)表示我们等待example.isFlag()返回true。ackage com.et;import org.awaitility.Awaitility;import java.util.concurrent.TimeUnit;import java.util.concurrent.ExecutorService;import java.util.concurrent.Executors;public class AwaitilityExample {private volatile boolean flag false;public void startAsyncTask() {ExecutorService executor Executors.newSingleThreadExecutor();executor.submit(() - {try {// mock asyncThread.sleep(5000);flag true;} catch (InterruptedException e) {Thread.currentThread().interrupt();}});executor.shutdown();}public boolean isFlag() {return flag;}public static void main(String[] args) {AwaitilityExample example new AwaitilityExample();example.startAsyncTask();// use Awaitility to wait flag for trueAwaitility.await().atMost(5, TimeUnit.SECONDS).until(example::isFlag);System.out.println(Flag is now true!);}}以上只是一些关键代码所有代码请参见下面代码仓库代码仓库https://github.com/Harries/Java-demo(awaitility )3.测试代码3-1.默认等待时间await().until(Callable conditionEvaluator) 最多等待 10s 直到 conditionEvaluator 满足条件否则 ConditionTimeoutException。public void testAsynchronousNormal() {AwaitilityExample example new AwaitilityExample();example.startAsyncTask();try {// Default timeout is 10 seconds. If the condition is not met within this period, a ConditionTimeoutException is thrownAwaitility.await().until(new CallableBoolean() {Overridepublic Boolean call() throws Exception {return example.isFlag();}});} catch (Exception e) {Assertions.fail(Run exception: e.getMessage() , error: e.getStackTrace()[0].toString());}}3-2.最多等待await().atMost() 设置最多等待时间如果在这时间内条件还不满足将抛出 ConditionTimeoutException。Testpublic void testAsynchronousAtMost() {AwaitilityExample example new AwaitilityExample();example.startAsyncTask();try {// Specify a timeout of 3 seconds. If the condition is not met within this period, a ConditionTimeoutException is thrownAwaitility.await().atMost(3, SECONDS).until(new CallableBoolean() {Overridepublic Boolean call() throws Exception {return example.isFlag();}});} catch (Exception e) {Assertions.fail(Run exception: e.getMessage() , error: e.getStackTrace()[0].toString());}}3-3.至少等待await().atLeast() 设置至少等待时间多个条件时候用 and() 连接。Testpublic void testAsynchronousAtLeast() {AwaitilityExample example new AwaitilityExample();example.startAsyncTask();try {// Specify at least 1 second and at most 3 seconds. If the condition is not met within this period, a ConditionTimeoutException is thrownAwaitility.await().atLeast(1, SECONDS).and().atMost(3, SECONDS).until(new CallableBoolean() {Overridepublic Boolean call() throws Exception {return example.isFlag();}});} catch (Exception e) {Assertions.fail(Run exception: e.getMessage() , error: e.getStackTrace()[0].toString());}}3-4.轮询with().pollInterval(ONE_HUNDRED_MILLISECONDS).and().with().pollDelay(50, MILLISECONDS) that is conditions are checked after 50ms then 50ms100ms。Testpublic void testAsynchronousPoll() {AwaitilityExample example new AwaitilityExample();example.startAsyncTask();try {// Polling query, pollInterval specifies how often to poll, pollDelay specifies the delay between each pollAwaitility.with().pollInterval(ONE_HUNDRED_MILLISECONDS).and().with().pollDelay(50, MILLISECONDS).await(count is greater 3).until(new CallableBoolean() {Overridepublic Boolean call() throws Exception {return example.isFlag();}});} catch (Exception e) {Assertions.fail(Run exception: e.getMessage() , error: e.getStackTrace()[0].toString());}}3-5.Fibonacci 轮询with().pollInterval(fibonacci(SECONDS)) 非线性轮询按照 fibonacci 数轮询。Testpublic void testAsynchronousFibonacciPoll() {AwaitilityExample example new AwaitilityExample();example.startAsyncTask();try {// Use Fibonacci numbers as the interval: 1, 1, 2, 3, 5, 8,..., default unit is millisecondsAwaitility.with().pollInterval(fibonacci(SECONDS)).await(count is greater 3).until(new CallableBoolean() {Overridepublic Boolean call() throws Exception {return example.isFlag();}});} catch (Exception e) {Assertions.fail(Run exception: e.getMessage() , error: e.getStackTrace()[0].toString());}}4.引用https://github.com/awaitility/awaitilityhttps://www.liuhaihua.cn/archives/711844.html
版权声明:本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!

网站蜘蛛屏蔽怎样恢复自动app优化官网

棕榈酰三肽-28与细胞表面的特异性受体TGF-βII (TbRII)结合。该受体磷酸化受体TGF-βI (TbRI)生成活性受体复合物,进而磷酸化Smad 2或Smad 3蛋白。Smad 2或Smad 3与胞质 Smad 4蛋白形成复合物,从而使Smad复合物转位至细胞核。在细胞核内,增强…

张小明 2026/1/6 16:07:30 网站建设

服装网站建设策划书论文wordpress站点维护

SELinux策略分析方法详解 1. 初步角色分析 在SELinux策略分析中,可使用 sesearch 工具进行初步的角色分析。 - --role_allow 选项:用于显示允许的角色。例如,执行以下命令: $ sesearch --role_allow -s webadm_r allow webadm_r system_r;此命令显示 webadm_r 角…

张小明 2026/1/7 18:20:08 网站建设

台州城乡建设局网站做网站都需要什么东西

目录已开发项目效果实现截图关于我系统介绍开发技术路线核心代码参考示例本项目开发思路结论源码lw获取/同行可拿货,招校园代理 :文章底部获取博主联系方式!已开发项目效果实现截图 同行可拿货,招校园代理 pythonweb_k93i56u_pycharmVuedjango 项…

张小明 2026/1/8 18:33:20 网站建设

济源专业做网站公司flash素材网站

终极指南:掌握AutoClicker鼠标自动化工具的10个高效技巧 【免费下载链接】AutoClicker AutoClicker is a useful simple tool for automating mouse clicks. 项目地址: https://gitcode.com/gh_mirrors/au/AutoClicker 还在为重复的鼠标点击任务感到疲惫吗&a…

张小明 2025/12/22 23:57:43 网站建设

西安做网站的在哪3d房屋建筑设计软件

仿写Prompt:通达信数据接口实战指南 【免费下载链接】mootdx 通达信数据读取的一个简便使用封装 项目地址: https://gitcode.com/GitHub_Trending/mo/mootdx 文章标题: 5个步骤,零基础掌握通达信股票数据获取技巧 副标题:…

张小明 2026/1/2 8:01:02 网站建设

可以兼职做设计的网站揭阳网站如何制作

百度网盘秒传工具实战指南:从零开始掌握高效文件管理 【免费下载链接】baidupan-rapidupload 百度网盘秒传链接转存/生成/转换 网页工具 (全平台可用) 项目地址: https://gitcode.com/gh_mirrors/bai/baidupan-rapidupload 作为一名长期受限于百度网盘下载速…

张小明 2026/1/6 14:35:21 网站建设