Flowable 6.6.0 表单 - 3.Spring 集成 - 3.3 单元测试(Unit testing)

推荐Flowable 6.6.0 用户指南相关文档下载

精编Flowable 6.6.0 应用程序指南中文PDF版
精编Flowable 6.6.0 表单用户指南中文PDF版

Flowable 6.6.0表单用户指南(Forms User Guide)

3.Spring 集成(Spring integration)

3.3 单元测试(Unit testing)

When integrating with Spring, forms can be tested very easily using the standard Flowable testing facilities. The following examples show how a form is tested in a typical Spring-based JUnit 4 and 5 tests:
当与Spring集成时,可以使用标准的Flowable测试设施(Flowable testing facilities)非常容易地测试表单。以下示例显示了如何在基于Spring的典型JUnit 4和5测试中测试表单:
JUnit 5 test.

@ExtendWith(FlowableFormSpringExtension.class)
@ExtendWith(SpringExtension.class)
@ContextConfiguration(classes = SpringJunitJupiterTest.TestConfiguration.class)
public class SpringJunit4Test {

    @Autowired
    private FormEngine formEngine;

    @Autowired
    private FormService formService;

    @Test
    @FormDeploymentAnnotation
    public void simpleFormInstanceTest() {
        FormInstance result = formService.getFormInstanceModelById(
            "f7689f79-f1cc-11e6-8549-acde48001122", null);

        Assertions.assertNotNull(result));
    }
}

Using the FlowableFormSpringExtension allows the usage of the Deployment annotation.
使用FlowableFormSpringExtension允许使用部署注释。
JUnit 4 test.

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:org/flowable/spring/test/junit4/springTypicalUsageTest-context.xml")
public class SpringJunit4Test {

    @Autowired
    private FormEngine formEngine;

    @Autowired
    private FormService formService;

    @Autowired
    @Rule
    public FlowableFormRule flowableSpringRule;

    @Test
    @FormDeploymentAnnotation
    public void simpleFormInstanceTest() {
        FormInstance result = formService.getFormInstanceModelById(
            "f7689f79-f1cc-11e6-8549-acde48001122", null);

        Assert.assertNotNull(result));
    }
}

Note that for this to work, you need to define a org.flowable.form.engine.test.FlowableFormRule bean in the Spring configuration (which is injected by auto-wiring in the example above).
请注意,要使其工作,您需要定义一个Spring配置中的org.flowable.form.engine.test.FlowableFormRule bean(在上面的例子中是通过auto-wiring注入的)。

<bean id="flowableFormRule" class="org.flowable.form.engine.test.FlowableFormRule">
    <property name="formEngine" ref="formEngine"/>
</bean>

限于篇幅,更多Flowable 6.6.0 表单用户指南的内容,请参考:

Flowable 6.6.0 表单用户指南》中文PDF版

目录

1 配置(Configuration) 5
1.1 创建一个表单引擎(Creating a Form Engine) 5
1.2 FormEngineConfiguration bean 7
1.3 插入流程引擎(Plug into Process Engine) 8
1.4 数据库配置(Database configuration) 9
1.5 JNDI数据源配置(JNDI Datasource Configuration) 12
1.5.1 Configuration 13
1.5.2 JNDI properties 14
1.5.3 自定义属性(Custom properties) 14
1.6 支持的数据库(Supported databases) 16
1.7 创建数据库表(Creating the database tables) 16
1.8 数据库表名解释(Database table names explained) 17
1.9 数据库升级(Database upgrade) 18
1.10 部署缓存配置(Deployment cache configuration) 19
1.11 日志(Logging) 20
2 Flowable表单API(The Flowable Form API) 21
2.1 表单引擎API及服务(The Form Engine API and services) 21
2.2 异常策略(Exception strategy) 24
2.3 查询API(Query API) 25
2.4 单元测试(Unit testing) 26
2.5 Web应用程序中的表单引擎(The Form engine in a web application) 29
3 Spring 集成(Spring integration) 31
3.1 FormEngineFactoryBean 31
3.2 自动资源部署(Automatic resource deployment) 31
3.3 单元测试(Unit testing) 34
4 部署(Deployment) 36
4.1 表单定义(Form Definitions) 36
4.1.1 表单定义(Form Definitions) 36
4.1.2 编程方式部署(Deploying programmatically) 36
4.2 表单定义的版本化(Versioning of Form definitions) 37
4.3 类别(Category) 39
5 表单简介(Form Introduction) 40
5.1 什么是表单定义(What is a form definition? ) 40
5.2 定义一个表单(Defining a form) 40
6 REST API 43
6.1 Flowable REST 一般原则(General Flowable REST principles) 43
6.1.1 安装与认证(Installation and Authentication) 43
6.1.2 配置(Configuration) 45
6.1.3 Tomcat中的使用(Usage in Tomcat) 45
6.1.4 方法与返回码(Methods and return-codes) 46
6.1.5 错误response body (Error response body) 48
6.1.6 请求参数(Request parameters) 48
6.2 部署(Deployment) 55
6.2.1 部署列表(List of Deployments) 55
6.2.2 获取一个部署(Get a deployment) 56
6.2.3 创建一个新部署(Create a new deployment) 57
6.2.4 删除一个部署(Delete a deployment) 58
6.2.5 获取一个部署资源内容(Get a deployment resource content) 58
6.3 表单定义(Form Definitions) 59
6.3.1 表单定义列表(List of Form definitions) 59
6.3.2 获取一个表单定义(Get a form definition) 61
6.3.3 获取一个表单定义资源内容(Get a form definition resource content) 62
6.3.4 获取一个表单定义表单模型(Get a form definition Form model) 62
6.4 表单实例(Form Instances) 63
6.4.1 获取一个表单实例(Get a form instance) 63
6.4.2 存储一个表单实例(Store a form instance) 64
6.4.3 表单实例列表(List of form instances) 65
6.4.4 查询表单实例(Query form instances) 68
6.5 表单引擎(Form Engine) 69
6.5.1 获取表单引擎信息(Get form engine info) 69

上一篇:安装Speedtest到Python


下一篇:持续集成