Skip to content

Commit

Permalink
修正了测试类
Browse files Browse the repository at this point in the history
  • Loading branch information
bluejoe2008 committed Jan 10, 2015
1 parent 05ef506 commit 8cde117
Show file tree
Hide file tree
Showing 35 changed files with 259 additions and 126 deletions.
12 changes: 8 additions & 4 deletions .classpath
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/main/java"/>
<classpathentry kind="src" path="src/test/java"/>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jre6"/>
<classpathentry kind="src" output="target/classes" path="src/main/java"/>
<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="org.eclipse.jst.component.nondependency" value=""/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jre6"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
38 changes: 35 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,22 @@
<modelVersion>4.0.0</modelVersion>
<groupId>openwebflow</groupId>
<artifactId>openwebflow</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>0.9-SNAPSHOT</version>
<packaging>jar</packaging>
<name>openwebflow</name>
<url>http://maven.apache.org</url>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>

<properties>
<org.springframework-version>3.2.4.RELEASE</org.springframework-version>
<activiti-version>5.16.1</activiti-version>
Expand Down Expand Up @@ -46,21 +61,38 @@
<artifactId>commons-collections</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${org.springframework-version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${org.springframework-version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${org.springframework-version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>4.0.6.RELEASE</version>
<version>${org.springframework-version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.0.6.RELEASE</version>
<version>${org.springframework-version}</version>
</dependency>
<!--
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>3.2.5.RELEASE</version>
</dependency>
-->
<!-- activiti工作流引擎 -->
<dependency>
<groupId>org.activiti</groupId>
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/log4j.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - %m%n

log4j.logger.org.openwebflow=warn
log4j.logger.org.openwebflow=info
log4j.logger.org.activiti.engine.impl.persistence.entity=warn
log4j.logger.org.springframework=warn
log4j.logger.org.activiti.engine.impl.db.DbSqlSession=debug
log4j.logger.org.activiti.engine.impl.db.DbSqlSession=warn
37 changes: 14 additions & 23 deletions src/main/java/org/openwebflow/alarm/impl/TaskAlarmServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import java.util.Date;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.task.Task;
Expand All @@ -19,13 +21,11 @@

public class TaskAlarmServiceImpl implements TaskAlarmService, DisposableBean
{
class MonitorThread extends Thread
class MonitorTask extends TimerTask
{
Period _parsedPeriodInAdvance;

boolean _stopped = false;

public MonitorThread()
public MonitorTask()
{
_parsedPeriodInAdvance = Period.parse(_periodInAdvance);
}
Expand Down Expand Up @@ -56,17 +56,13 @@ private void checkAndNotify() throws Exception
@Override
public void run()
{
while (!_stopped)
try
{
try
{
checkAndNotify();
Thread.sleep(_checkInterval);
}
catch (Exception e)
{
e.printStackTrace();
}
checkAndNotify();
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
Expand All @@ -83,17 +79,14 @@ public void run()

ProcessEngine _processEngine;

MonitorThread _thread;

UserDetailsManager _userDetailsManager;

private Timer _monitorTimer = new Timer(true);

@Override
public void destroy() throws Exception
{
if (_thread != null)
{
_thread._stopped = true;
}
_monitorTimer.cancel();
}

public long getCheckInterval()
Expand Down Expand Up @@ -160,8 +153,6 @@ public void setUserDetailsManager(UserDetailsManager userDetailsManager)
public void start(ProcessEngine processEngine) throws Exception
{
_processEngine = processEngine;
_thread = new MonitorThread();
_thread.setName(_thread.getClass().getName());
_thread.start();
_monitorTimer.schedule(new MonitorTask(), _checkInterval, _checkInterval);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ public interface SqlNotificationDetailsMapper
{
@Select("SELECT * FROM OWF_NOTIFICATION where TASKID=#{taskId}")
@Results(value = { @Result(property = "opTime", column = "OP_TIME") })
List<SqlNotificationDetails> findByTaskId(@Param("taskId")
String taskId);
List<SqlNotificationDetails> findByTaskId(@Param("taskId") String taskId);

@Insert("INSERT INTO OWF_NOTIFICATION (TASKID,OPTIME) values (#{taskId},#{opTime})")
void saveNotificationDetails(SqlNotificationDetails sde);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ public interface SqlActivityAclStoreMapper
@Result(property = "assignee", column = "ASSIGNED_USER"),
@Result(property = "grantedGroupString", column = "GRANTED_GROUPS"),
@Result(property = "grantedUserString", column = "GRANTED_USERS") })
public SqlActivityAclEntry load(@Param("processDefinitionId")
String processDefinitionId, @Param("taskDefinitionKey")
String taskDefinitionKey);
public SqlActivityAclEntry load(@Param("processDefinitionId") String processDefinitionId,
@Param("taskDefinitionKey") String taskDefinitionKey);

@Delete("DELETE from OWF_ACTIVITY_ACL")
public void deleteAll();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ public interface SqlDelegationEntityMapper
{
@Select("SELECT * FROM OWF_DELEGATION where DELEGATED=#{delegated}")
@Results(value = { @Result(property = "opTime", column = "OP_TIME") })
List<SqlDelegationEntity> findByDelegated(@Param("delegated")
String delegated);
List<SqlDelegationEntity> findByDelegated(@Param("delegated") String delegated);

@Insert("INSERT INTO OWF_DELEGATION (DELEGATED,DELEGATE,OP_TIME) values (#{delegated},#{delegate},#{opTime})")
void saveDelegation(DelegationDetails sde);
Expand Down
15 changes: 11 additions & 4 deletions src/main/java/org/openwebflow/conf/ImportDefinedProcessModels.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.openwebflow.conf;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FilenameFilter;
import java.io.IOException;
import java.util.ArrayList;
Expand Down Expand Up @@ -37,8 +38,11 @@ public void checkAndImportNewModels(RepositoryService repositoryService) throws
}
}

private List<File> checkNewModelNames(RepositoryService repositoryService)
private List<File> checkNewModelNames(RepositoryService repositoryService) throws FileNotFoundException
{
if (!_modelDir.exists())
throw new FileNotFoundException(_modelDir.getPath());

File[] files = _modelDir.listFiles(new FilenameFilter()
{
@Override
Expand All @@ -49,11 +53,14 @@ public boolean accept(File dir, String name)
});

List<File> newModelFiles = new ArrayList<File>();
for (File file : files)
if (files != null)
{
if (!exists(repositoryService, file.getName()))
for (File file : files)
{
newModelFiles.add(file);
if (!exists(repositoryService, file.getName()))
{
newModelFiles.add(file);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
import org.openwebflow.util.ProcessDefinitionUtils;
import org.springframework.util.CollectionUtils;

import com.fasterxml.jackson.core.JsonProcessingException;

public class TaskFlowControlService
{
RuntimeActivityDefinitionStore _activitiesCreationStore;
Expand Down Expand Up @@ -172,7 +170,7 @@ public void moveTo(TaskEntity currentTaskEntity, String targetTaskDefinitionKey)
moveTo(currentTaskEntity, activity);
}

private void recordActivitiesCreation(RuntimeActivityDefinition info) throws JsonProcessingException
private void recordActivitiesCreation(RuntimeActivityDefinition info) throws Exception
{
info.serializeProperties();
_activitiesCreationStore.save(info);
Expand All @@ -188,7 +186,7 @@ private void recordActivitiesCreation(RuntimeActivityDefinition info) throws Jso
* @throws IllegalArgumentException
*/
public ActivityImpl split(String targetTaskDefinitionKey, boolean isSequential, String... assignees)
throws IOException
throws Exception
{
RuntimeActivityDefinition info = new RuntimeActivityDefinition();
info.setProcessDefinitionId(_processDefinition.getId());
Expand All @@ -208,7 +206,7 @@ public ActivityImpl split(String targetTaskDefinitionKey, boolean isSequential,
return clone;
}

public ActivityImpl split(String targetTaskDefinitionKey, String... assignee) throws IOException
public ActivityImpl split(String targetTaskDefinitionKey, String... assignee) throws Exception
{
return split(targetTaskDefinitionKey, true, assignee);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
public interface RuntimeActivityDefinitionStore
{

List<RuntimeActivityDefinition> loadAll();
List<RuntimeActivityDefinition> loadAll() throws Exception;

void save(RuntimeActivityDefinition entity);
void save(RuntimeActivityDefinition entity) throws Exception;

void removeAll();
void removeAll() throws Exception;

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@
public interface SqlMembershipMapper
{
@Select("SELECT * FROM OWF_MEMBERSHIP where USERID=#{userId}")
List<SqlMembershipEntity> findMembershipsByUserId(@Param("userId")
String userId);
List<SqlMembershipEntity> findMembershipsByUserId(@Param("userId") String userId);

@Select("SELECT * FROM OWF_MEMBERSHIP where GROUPID=#{groupId}")
List<SqlMembershipEntity> findMembershipsByGroupId(@Param("groupId")
String groupId);
List<SqlMembershipEntity> findMembershipsByGroupId(@Param("groupId") String groupId);

@Insert("INSERT INTO OWF_MEMBERSHIP (USERID,GROUPID) values (#{userId},#{groupId})")
void saveMembership(SqlMembershipEntity mse);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
public interface SqlUserDetailsMapper
{
@Select("SELECT * FROM OWF_USER where USERID=#{userId}")
IdentityUserDetails findUserById(@Param("userId")
String userId);
IdentityUserDetails findUserById(@Param("userId") String userId);

@Insert("INSERT INTO OWF_USER (USERID,EMAIL,NICKNAME,MOBILEPHONENUMBER) values (#{userId},#{email},#{nickName},#{mobilePhoneNumber})")
void saveUser(IdentityUserDetails userDetails);
Expand Down
26 changes: 11 additions & 15 deletions src/main/java/org/openwebflow/mvc/DefaultWebFlowController.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,17 @@ public class DefaultWebFlowController extends DefaultWebFlowControllerConfigurat
private ProcessEngineTool _processEngineTool;

@RequestMapping("claimTask.action")
public String claimTask(@WebFlowParam
ContextToolHolder holder)
public String claimTask(@WebFlowParam ContextToolHolder holder)
{
TaskTool tool = holder.getTaskTool();
tool.claim();
//FIXME
tool.claim("bluejoe");
return super.getDefaultClaimTaskActionView();
}

@RequestMapping("completeTaskForm.action")
public String completeTaskForm(@WebFlowParam
ContextToolHolder holder, ModelAndView mav, ModelMap model, HttpServletRequest request, HttpServletResponse response)
throws Exception
public String completeTaskForm(@WebFlowParam ContextToolHolder holder, ModelAndView mav, ModelMap model,
HttpServletRequest request, HttpServletResponse response) throws Exception
{
TaskTool tool = holder.getTaskTool();
Task task = tool.getTask();
Expand All @@ -74,9 +73,8 @@ public String completeTaskForm(@WebFlowParam
}

@RequestMapping("doCompleteTask.action")
public String doCompleteTask(String taskId, @WebFlowParam
ContextToolHolder holder, ModelAndView mav, ModelMap model, HttpServletRequest request, HttpServletResponse response)
throws Exception
public String doCompleteTask(String taskId, @WebFlowParam ContextToolHolder holder, ModelAndView mav,
ModelMap model, HttpServletRequest request, HttpServletResponse response) throws Exception
{
TaskTool tool = holder.getTaskTool();
Task task = tool.getTask();
Expand All @@ -102,9 +100,8 @@ public String doCompleteTask(String taskId, @WebFlowParam
}

@RequestMapping("doStartProcess.action")
public String doStartProcess(@WebFlowParam
ContextToolHolder holder, ModelAndView mav, ModelMap model, HttpServletRequest request, HttpServletResponse response)
throws Exception
public String doStartProcess(@WebFlowParam ContextToolHolder holder, ModelAndView mav, ModelMap model,
HttpServletRequest request, HttpServletResponse response) throws Exception
{
ProcessDefinitionTool tool = holder.getProcessDefinitionTool();
String startFormKey = tool.getStartFormKey();
Expand Down Expand Up @@ -164,9 +161,8 @@ private EventHandler getActionHandler(EventType eventType, String eventKey)
* @throws ServletException
*/
@RequestMapping("startProcessForm.action")
public String startProcessForm(@WebFlowParam
ContextToolHolder holder, ModelAndView mav, ModelMap model, HttpServletRequest request, HttpServletResponse response)
throws Exception
public String startProcessForm(@WebFlowParam ContextToolHolder holder, ModelAndView mav, ModelMap model,
HttpServletRequest request, HttpServletResponse response) throws Exception
{
ProcessDefinitionTool tool = holder.getProcessDefinitionTool();
model.put("processDef", tool.getProcessDefinition());
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/org/openwebflow/tool/ActivityTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

import org.activiti.engine.impl.pvm.process.ActivityImpl;

/**
* @deprecated
* @author [email protected]
*
*/
public interface ActivityTool
{
ActivityImpl getActivity();
Expand Down
Loading

0 comments on commit 8cde117

Please sign in to comment.