Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
开发团队
Flowable Engine
提交
1247a9bc
F
Flowable Engine
项目概览
开发团队
/
Flowable Engine
通知
9
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
Flowable Engine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
1247a9bc
编写于
2月 22, 2013
作者:
T
tijsrademakers
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of
https://github.com/Activiti/Activiti
上级
71160d7f
8ca4c619
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
269 addition
and
9 deletion
+269
-9
modules/activiti-cdi/src/main/java/org/activiti/cdi/impl/util/ProgrammaticBeanLookup.java
...va/org/activiti/cdi/impl/util/ProgrammaticBeanLookup.java
+4
-3
modules/activiti-cdi/src/test/java/org/activiti/cdi/test/impl/beans/SpecializedTestBean.java
...org/activiti/cdi/test/impl/beans/SpecializedTestBean.java
+10
-0
modules/activiti-cdi/src/test/java/org/activiti/cdi/test/impl/util/ProgrammaticBeanLookupTest.java
...tiviti/cdi/test/impl/util/ProgrammaticBeanLookupTest.java
+106
-0
modules/activiti-cdi/src/test/resources/org/activiti/cdi/test/impl/util/beans.xml
.../test/resources/org/activiti/cdi/test/impl/util/beans.xml
+4
-0
modules/activiti-cdi/src/test/resources/org/activiti/cdi/test/impl/util/beansWithAlternative.xml
.../org/activiti/cdi/test/impl/util/beansWithAlternative.xml
+7
-0
modules/activiti-engine/src/main/java/org/activiti/engine/impl/pvm/runtime/AtomicOperationActivityEnd.java
...i/engine/impl/pvm/runtime/AtomicOperationActivityEnd.java
+8
-5
modules/activiti-engine/src/test/java/org/activiti/engine/test/bpmn/event/error/BoundaryErrorEventTest.java
.../engine/test/bpmn/event/error/BoundaryErrorEventTest.java
+30
-1
modules/activiti-engine/src/test/resources/org/activiti/engine/test/bpmn/event/error/BoundaryErrorEventTest.testCatchErrorOnScriptTask.bpmn20.xml
...ndaryErrorEventTest.testCatchErrorOnScriptTask.bpmn20.xml
+34
-0
modules/activiti-engine/src/test/resources/org/activiti/engine/test/bpmn/event/error/BoundaryErrorEventTest.testUncaughtErrorOnScriptTask.bpmn20.xml
...ryErrorEventTest.testUncaughtErrorOnScriptTask.bpmn20.xml
+34
-0
modules/activiti-engine/src/test/resources/org/activiti/engine/test/bpmn/event/error/BoundaryErrorEventTest.testUncaughtErrorOnScriptTaskWithEmptyErrorEventDefinition.bpmn20.xml
...ErrorOnScriptTaskWithEmptyErrorEventDefinition.bpmn20.xml
+32
-0
未找到文件。
modules/activiti-cdi/src/main/java/org/activiti/cdi/impl/util/ProgrammaticBeanLookup.java
浏览文件 @
1247a9bc
...
...
@@ -14,6 +14,7 @@ package org.activiti.cdi.impl.util;
import
java.lang.reflect.Type
;
import
java.util.Iterator
;
import
java.util.Set
;
import
javax.enterprise.context.spi.CreationalContext
;
import
javax.enterprise.inject.spi.Bean
;
...
...
@@ -40,11 +41,11 @@ public class ProgrammaticBeanLookup {
@SuppressWarnings
({
"unchecked"
,
"rawtypes"
})
public
static
Object
lookup
(
String
name
,
BeanManager
bm
)
{
Iterator
<
Bean
<
?
>>
iter
=
bm
.
getBeans
(
name
).
iterator
(
);
if
(
!
iter
.
hasNext
())
{
Set
<
Bean
<
?
>>
beans
=
bm
.
getBeans
(
name
);
if
(
beans
.
isEmpty
())
{
throw
new
IllegalStateException
(
"CDI BeanManager cannot find an instance of requested type '"
+
name
+
"'"
);
}
Bean
bean
=
iter
.
next
(
);
Bean
bean
=
bm
.
resolve
(
beans
);
CreationalContext
ctx
=
bm
.
createCreationalContext
(
bean
);
// select one beantype randomly. A bean has a non-empty set of beantypes.
Type
type
=
(
Type
)
bean
.
getTypes
().
iterator
().
next
();
...
...
modules/activiti-cdi/src/test/java/org/activiti/cdi/test/impl/beans/SpecializedTestBean.java
0 → 100644
浏览文件 @
1247a9bc
package
org.activiti.cdi.test.impl.beans
;
import
javax.enterprise.inject.Specializes
;
import
org.activiti.cdi.test.impl.util.ProgrammaticBeanLookupTest.TestBean
;
@Specializes
public
class
SpecializedTestBean
extends
TestBean
{
}
modules/activiti-cdi/src/test/java/org/activiti/cdi/test/impl/util/ProgrammaticBeanLookupTest.java
0 → 100644
浏览文件 @
1247a9bc
package
org.activiti.cdi.test.impl.util
;
import
static
org
.
hamcrest
.
core
.
Is
.
is
;
import
static
org
.
hamcrest
.
core
.
IsEqual
.
equalTo
;
import
static
org
.
junit
.
Assert
.
assertThat
;
import
javax.enterprise.inject.Alternative
;
import
javax.inject.Named
;
import
org.activiti.cdi.impl.util.ActivitiServices
;
import
org.activiti.cdi.impl.util.ProgrammaticBeanLookup
;
import
org.activiti.cdi.test.impl.beans.SpecializedTestBean
;
import
org.jboss.arquillian.container.test.api.Deployer
;
import
org.jboss.arquillian.container.test.api.Deployment
;
import
org.jboss.arquillian.junit.Arquillian
;
import
org.jboss.arquillian.test.api.ArquillianResource
;
import
org.jboss.shrinkwrap.api.ShrinkWrap
;
import
org.jboss.shrinkwrap.api.spec.JavaArchive
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
/**
*
* @author Ronny Bräunlich
*
*/
@RunWith
(
Arquillian
.
class
)
public
class
ProgrammaticBeanLookupTest
{
/**
* Because of all alternatives and specializations I have to handle
* deployment myself
*/
@ArquillianResource
private
Deployer
deployer
;
@Deployment
(
name
=
"normal"
,
managed
=
false
)
public
static
JavaArchive
createDeployment
()
{
return
ShrinkWrap
.
create
(
JavaArchive
.
class
)
.
addClass
(
ProgrammaticBeanLookup
.
class
)
.
addClass
(
ActivitiServices
.
class
)
.
addAsManifestResource
(
"org/activiti/cdi/test/impl/util/beans.xml"
,
"beans.xml"
);
}
@Deployment
(
name
=
"withAlternative"
,
managed
=
false
)
public
static
JavaArchive
createDeploymentWithAlternative
()
{
return
ShrinkWrap
.
create
(
JavaArchive
.
class
)
.
addClass
(
ProgrammaticBeanLookup
.
class
)
.
addClass
(
ActivitiServices
.
class
)
.
addClass
(
AlternativeTestBean
.
class
)
.
addAsManifestResource
(
"org/activiti/cdi/test/impl/util/beansWithAlternative.xml"
,
"beans.xml"
);
}
@Deployment
(
name
=
"withSpecialization"
,
managed
=
false
)
public
static
JavaArchive
createDeploymentWithSpecialization
()
{
return
ShrinkWrap
.
create
(
JavaArchive
.
class
)
.
addClass
(
ProgrammaticBeanLookup
.
class
)
.
addClass
(
ActivitiServices
.
class
)
.
addClass
(
SpecializedTestBean
.
class
)
.
addAsManifestResource
(
"org/activiti/cdi/test/impl/util/beans.xml"
,
"beans.xml"
);
}
@Test
public
void
testLookupBean
()
{
deployer
.
deploy
(
"normal"
);
Object
lookup
=
ProgrammaticBeanLookup
.
lookup
(
"testOnly"
);
assertThat
(
lookup
.
getClass
(),
is
(
TestBean
.
class
.
getClass
()));
deployer
.
undeploy
(
"normal"
);
}
@Test
public
void
testLookupShouldFindAlternative
()
{
deployer
.
deploy
(
"withAlternative"
);
Object
lookup
=
ProgrammaticBeanLookup
.
lookup
(
"testOnly"
);
assertThat
(
lookup
.
getClass
().
getName
(),
is
(
equalTo
(
AlternativeTestBean
.
class
.
getName
())));
deployer
.
undeploy
(
"withAlternative"
);
}
@Test
public
void
testLookupShouldFindSpecialization
()
{
deployer
.
deploy
(
"withSpecialization"
);
Object
lookup
=
ProgrammaticBeanLookup
.
lookup
(
"testOnly"
);
assertThat
(
lookup
.
getClass
().
getName
(),
is
(
equalTo
(
SpecializedTestBean
.
class
.
getName
())));
deployer
.
undeploy
(
"withSpecialization"
);
}
@Named
(
"testOnly"
)
public
static
class
TestBean
{
}
@Alternative
@Named
(
"testOnly"
)
public
static
class
AlternativeTestBean
extends
TestBean
{
}
}
modules/activiti-cdi/src/test/resources/org/activiti/cdi/test/impl/util/beans.xml
0 → 100644
浏览文件 @
1247a9bc
<?xml version="1.0" encoding="utf-8"?>
<beans
xmlns=
"http://java.sun.com/xml/ns/javaee"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd"
>
</beans>
\ No newline at end of file
modules/activiti-cdi/src/test/resources/org/activiti/cdi/test/impl/util/beansWithAlternative.xml
0 → 100644
浏览文件 @
1247a9bc
<?xml version="1.0" encoding="utf-8"?>
<beans
xmlns=
"http://java.sun.com/xml/ns/javaee"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd"
>
<alternatives>
<class>
org.activiti.cdi.test.impl.util.ProgrammaticBeanLookupTest$AlternativeTestBean
</class>
</alternatives>
</beans>
modules/activiti-engine/src/main/java/org/activiti/engine/impl/pvm/runtime/AtomicOperationActivityEnd.java
浏览文件 @
1247a9bc
...
...
@@ -77,12 +77,15 @@ public class AtomicOperationActivityEnd extends AbstractEventAtomicOperation {
execution
.
remove
();
// if we are a scope under the process instance
// and have no outgoing transitions: end the process instance here
if
(
activity
.
getParent
()
==
activity
.
getProcessDefinition
()
&&
activity
.
getOutgoingTransitions
().
isEmpty
())
{
if
(
activity
.
getParent
()
==
activity
.
getProcessDefinition
())
{
parentScopeExecution
.
setActivity
(
activity
);
// we call end() because it sets isEnded on the execution
parentScopeExecution
.
end
();
}
else
{
if
(
activity
.
getOutgoingTransitions
().
isEmpty
())
{
// we call end() because it sets isEnded on the execution
parentScopeExecution
.
end
();
}
else
{
parentScopeExecution
.
performOperation
(
PROCESS_END
);
}
}
else
{
parentScopeExecution
.
setActivity
(
parentActivity
);
parentScopeExecution
.
performOperation
(
ACTIVITY_END
);
}
...
...
modules/activiti-engine/src/test/java/org/activiti/engine/test/bpmn/event/error/BoundaryErrorEventTest.java
浏览文件 @
1247a9bc
...
...
@@ -22,6 +22,7 @@ import org.activiti.engine.history.HistoricProcessInstance;
import
org.activiti.engine.impl.history.HistoryLevel
;
import
org.activiti.engine.impl.test.PluggableActivitiTestCase
;
import
org.activiti.engine.impl.util.CollectionUtil
;
import
org.activiti.engine.runtime.ProcessInstance
;
import
org.activiti.engine.task.Task
;
import
org.activiti.engine.test.Deployment
;
...
...
@@ -378,7 +379,35 @@ public class BoundaryErrorEventTest extends PluggableActivitiTestCase {
assertTextPresent
(
"No catching boundary event found for error with errorCode '23', neither in same process nor in parent process"
,
e
.
getMessage
());
}
}
@Deployment
(
resources
=
{
"org/activiti/engine/test/bpmn/event/error/BoundaryErrorEventTest.testCatchErrorOnScriptTask.bpmn20.xml"
})
public
void
testCatchErrorOnScriptTask
()
{
String
procId
=
runtimeService
.
startProcessInstanceByKey
(
"catchErrorOnScriptTask"
).
getId
();
assertProcessEnded
(
procId
);
}
@Deployment
(
resources
=
{
"org/activiti/engine/test/bpmn/event/error/BoundaryErrorEventTest.testUncaughtErrorOnScriptTaskWithEmptyErrorEventDefinition.bpmn20.xml"
})
public
void
testUncaughtErrorOnScriptTaskWithEmptyErrorEventDefinition
()
{
String
procId
=
runtimeService
.
startProcessInstanceByKey
(
"uncaughtErrorOnScriptTaskWithEmptyErrorEventDefinition"
).
getId
();
assertProcessEnded
(
procId
);
}
@Deployment
(
resources
=
{
"org/activiti/engine/test/bpmn/event/error/BoundaryErrorEventTest.testUncaughtErrorOnScriptTask.bpmn20.xml"
})
public
void
testUncaughtErrorOnScriptTask
()
{
try
{
String
procId
=
runtimeService
.
startProcessInstanceByKey
(
"uncaughtErrorOnScriptTask"
).
getId
();
assertProcessEnded
(
procId
);
}
catch
(
NullPointerException
e
)
{
fail
(
"The script throws error event with errorCode 'errorUncaught', but no catching boundary event was defined. Execution should simply be ended (none end event semantics)."
);
}
}
@Deployment
public
void
testCatchErrorThrownByJavaDelegateOnMultiInstanceServiceTaskSequential
()
{
Map
<
String
,
Object
>
variables
=
new
HashMap
<
String
,
Object
>();
...
...
modules/activiti-engine/src/test/resources/org/activiti/engine/test/bpmn/event/error/BoundaryErrorEventTest.testCatchErrorOnScriptTask.bpmn20.xml
0 → 100644
浏览文件 @
1247a9bc
<?xml version="1.0" encoding="UTF-8"?>
<definitions
id=
"definitions"
xmlns=
"http://www.omg.org/spec/BPMN/20100524/MODEL"
xmlns:activiti=
"http://activiti.org/bpmn"
targetNamespace=
"Examples"
>
<error
id=
"errorOne"
name=
"Error One"
errorCode=
"errorOne"
/>
<process
id=
"catchErrorOnScriptTask"
>
<startEvent
id=
"theStart"
/>
<sequenceFlow
id=
"flow1"
sourceRef=
"theStart"
targetRef=
"theScript"
/>
<scriptTask
id=
"theScript"
scriptFormat=
"groovy"
>
<script>
<![CDATA[
import org.activiti.engine.delegate.BpmnError;
throw new BpmnError("errorOne");
]]>
</script>
</scriptTask>
<sequenceFlow
id=
"flow4"
sourceRef=
"theScript"
targetRef=
"theEnd"
/>
<boundaryEvent
id=
"catchError"
attachedToRef=
"theScript"
cancelActivity=
"true"
>
<errorEventDefinition
id=
"one"
errorRef=
"errorOne"
/>
</boundaryEvent>
<sequenceFlow
id=
"errorFlow"
sourceRef=
"catchError"
targetRef=
"theEnd"
/>
<endEvent
id=
"theEnd"
/>
</process>
</definitions>
\ No newline at end of file
modules/activiti-engine/src/test/resources/org/activiti/engine/test/bpmn/event/error/BoundaryErrorEventTest.testUncaughtErrorOnScriptTask.bpmn20.xml
0 → 100644
浏览文件 @
1247a9bc
<?xml version="1.0" encoding="UTF-8"?>
<definitions
id=
"definitions"
xmlns=
"http://www.omg.org/spec/BPMN/20100524/MODEL"
xmlns:activiti=
"http://activiti.org/bpmn"
targetNamespace=
"Examples"
>
<error
id=
"errorOne"
name=
"Error One"
errorCode=
"errorOne"
/>
<process
id=
"uncaughtErrorOnScriptTask"
>
<startEvent
id=
"theStart"
/>
<sequenceFlow
id=
"flow1"
sourceRef=
"theStart"
targetRef=
"theScript"
/>
<scriptTask
id=
"theScript"
scriptFormat=
"groovy"
>
<script>
<![CDATA[
import org.activiti.engine.delegate.BpmnError;
throw new BpmnError("errorUncaught"); // non-defined error code!
]]>
</script>
</scriptTask>
<sequenceFlow
id=
"flow4"
sourceRef=
"theScript"
targetRef=
"theEnd"
/>
<boundaryEvent
id=
"catchErrorOne"
attachedToRef=
"theScript"
cancelActivity=
"true"
>
<errorEventDefinition
id=
"one"
errorRef=
"errorOne"
/>
</boundaryEvent>
<sequenceFlow
id=
"errorFlow"
sourceRef=
"catchErrorOne"
targetRef=
"theEnd"
/>
<endEvent
id=
"theEnd"
/>
</process>
</definitions>
\ No newline at end of file
modules/activiti-engine/src/test/resources/org/activiti/engine/test/bpmn/event/error/BoundaryErrorEventTest.testUncaughtErrorOnScriptTaskWithEmptyErrorEventDefinition.bpmn20.xml
0 → 100644
浏览文件 @
1247a9bc
<?xml version="1.0" encoding="UTF-8"?>
<definitions
id=
"definitions"
xmlns=
"http://www.omg.org/spec/BPMN/20100524/MODEL"
xmlns:activiti=
"http://activiti.org/bpmn"
targetNamespace=
"Examples"
>
<process
id=
"uncaughtErrorOnScriptTaskWithEmptyErrorEventDefinition"
>
<startEvent
id=
"theStart"
/>
<sequenceFlow
id=
"flow1"
sourceRef=
"theStart"
targetRef=
"theScript"
/>
<scriptTask
id=
"theScript"
scriptFormat=
"groovy"
>
<script>
<![CDATA[
import org.activiti.engine.delegate.BpmnError;
throw new BpmnError("errorUncaught"); // non-defined error code!
]]>
</script>
</scriptTask>
<sequenceFlow
id=
"flow4"
sourceRef=
"theScript"
targetRef=
"theEnd"
/>
<boundaryEvent
id=
"catchAnyError"
attachedToRef=
"theScript"
cancelActivity=
"true"
>
<errorEventDefinition
/>
<!-- no errorCode: catch any error -->
</boundaryEvent>
<sequenceFlow
id=
"errorFlow"
sourceRef=
"catchAnyError"
targetRef=
"theEnd"
/>
<endEvent
id=
"theEnd"
/>
</process>
</definitions>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录