Permalink
Browse files

Fixing/adding/refactoring tests (actually, procastinating from packin…

…g, but these are test fixes)
  • Loading branch information...
1 parent 9841215 commit 4ad2e932535be5749f1fb69423670f47ee9b227b @mrietveld mrietveld committed Mar 2, 2012
Showing with 76 additions and 159 deletions.
  1. +39 −8 jbpm-human-task/src/test/java/org/jbpm/task/service/TaskServiceTaskAttributesBaseTest.java
  2. +3 −50 ...-task/src/test/java/org/jbpm/task/service/TaskServiceTaskAttributesBaseUserGroupCallbackTest.java
  3. +2 −8 ...rc/test/java/org/jbpm/task/service/base/async/TaskServiceCommentsAndAttachmentsBaseAsyncTest.java
  4. +5 −48 ...n-task/src/test/java/org/jbpm/task/service/base/async/TaskServiceTaskAttributesBaseAsyncTest.java
  5. +7 −15 ...task/src/test/java/org/jbpm/task/service/test/TaskServiceTaskAttributesUserGroupCallbackTest.java
  6. +1 −1 jbpm-human-task/src/test/java/org/jbpm/task/service/test/async/ClaimTaskTwiceAsyncTest.java
  7. +1 −1 jbpm-human-task/src/test/java/org/jbpm/task/service/test/async/IcalAsyncTest.java
  8. +2 −4 ...a/org/jbpm/task/service/test/async/{TaskServiceHornetQAsyncTest.java → TaskServiceAsyncTest.java}
  9. +2 −4 ...iceCommentsAndAttachmentsHornetQAsyncTest.java → TaskServiceCommentsAndAttachmentsAsyncTest.java}
  10. +2 −4 ...rvice/test/async/{TaskServiceDeadlinesHornetQAsyncTest.java → TaskServiceDeadlinesAsyncTest.java}
  11. +2 −4 ...ice/test/async/{TaskServiceEscalationHornetQAsyncTest.java → TaskServiceEscalationAsyncTest.java}
  12. +2 −4 .../async/{TaskServiceEventMessagingHornetQAsyncTest.java → TaskServiceEventMessagingAsyncTest.java}
  13. +2 −4 ...rvice/test/async/{TaskServiceLifeCycleHornetQAsyncTest.java → TaskServiceLifeCycleAsyncTest.java}
  14. +2 −4 .../async/{TaskServiceTaskAttributesHornetQAsyncTest.java → TaskServiceTaskAttributesAsyncTest.java}
  15. +4 −0 jbpm-human-task/src/test/java/org/jbpm/task/service/test/impl/TestServerUtil.java
@@ -17,6 +17,7 @@
package org.jbpm.task.service;
import java.io.StringReader;
+import java.lang.reflect.Method;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
@@ -180,11 +181,10 @@ public void testAddRemoveFault() throws Exception {
}
public void testSetPriority() throws Exception {
- Map vars = new HashMap();
- vars.put( "users", users );
- vars.put( "groups", groups );
- vars.put( "now", new Date() );
-
+ testSetPriority(fillVariables(), client);
+ }
+
+ public static void testSetPriority(Map vars, Object client) throws Exception {
String str = "(with (new Task()) { priority = 55, taskData = (with( new TaskData()) { createdOn = now, activationTime = now,";
str += "actualOwner = new User('Darth Vader')}),";
str += "deadlines = new Deadlines(),";
@@ -194,19 +194,38 @@ public void testSetPriority() throws Exception {
BlockingAddTaskResponseHandler addTaskResponseHandler = new BlockingAddTaskResponseHandler();
Task task = ( Task ) eval( new StringReader( str ), vars );
- client.addTask( task, null, addTaskResponseHandler );
+
+ try {
+ Method addTaskMethod = getMethod(client, "addTask");
+ addTaskMethod.invoke(client, task, null, addTaskResponseHandler );
+ } catch(Exception e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
long taskId = addTaskResponseHandler.getTaskId();
int newPriority = 33;
BlockingTaskOperationResponseHandler setPriorityResponseHandler = new BlockingTaskOperationResponseHandler();
- client.setPriority(taskId, "Darth Vader", newPriority, setPriorityResponseHandler );
+ try {
+ Method setPriorityMethod = getMethod(client, "setPriority");
+ setPriorityMethod.invoke(client, taskId, "Darth Vader", newPriority, setPriorityResponseHandler );
+ } catch(Exception e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
setPriorityResponseHandler.waitTillDone(1000);
assertFalse( setPriorityResponseHandler.hasError() );
BlockingGetTaskResponseHandler getTaskResponseHandler = new BlockingGetTaskResponseHandler();
- client.getTask( taskId, getTaskResponseHandler );
+ try {
+ Method getTaskMethod = getMethod(client, "getTask");
+ getTaskMethod.invoke(client, taskId, getTaskResponseHandler);
+ } catch(Exception e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
Task task1 = getTaskResponseHandler.getTask();
assertNotSame(task, task1);
assertFalse( task.equals( task1) );
@@ -219,4 +238,16 @@ public void testSetPriority() throws Exception {
task.getTaskData().setStatus( Status.Created );
assertEquals(task, task1);
}
+
+ private static Method getMethod(Object object, String methodName) {
+ Method [] methods = object.getClass().getDeclaredMethods();
+ Method methodFound = null;
+ for( int i = 0; i < methods.length; ++i ) {
+ if( methodName.equals(methods[i].getName()) ) {
+ methodFound = methods[i];
+ break;
+ }
+ }
+ return methodFound;
+ }
}
@@ -16,8 +16,6 @@
package org.jbpm.task.service;
import java.io.StringReader;
-import java.util.Date;
-import java.util.HashMap;
import java.util.Map;
import org.jbpm.task.AccessType;
@@ -34,12 +32,8 @@
protected TaskServer server;
protected TaskClient client;
- @SuppressWarnings("unchecked")
public void testAddRemoveOutput() {
- Map vars = new HashMap();
- vars.put( "users", users );
- vars.put( "groups", groups );
- vars.put( "now", new Date() );
+ Map<String, Object> vars = fillVariables();
String str = "(with (new Task()) { priority = 55, taskData = (with( new TaskData()) { createdOn = now, activationTime = now,";
str += "actualOwner = new User('Darth Vader')}),";
@@ -102,10 +96,7 @@ public void testAddRemoveOutput() {
}
public void testAddRemoveFault() throws Exception {
- Map vars = new HashMap();
- vars.put( "users", users );
- vars.put( "groups", groups );
- vars.put( "now", new Date() );
+ Map<String, Object> vars = fillVariables();
String str = "(with (new Task()) { priority = 55, taskData = (with( new TaskData()) { createdOn = now, activationTime = now,";
str += "actualOwner = new User('Darth Vader')}),";
@@ -171,44 +162,6 @@ public void testAddRemoveFault() throws Exception {
}
public void testSetPriority() throws Exception {
- Map vars = new HashMap();
- vars.put( "users", users );
- vars.put( "groups", groups );
- vars.put( "now", new Date() );
-
- String str = "(with (new Task()) { priority = 55, taskData = (with( new TaskData()) { createdOn = now, activationTime = now,";
- str += "actualOwner = new User('Darth Vader')}),";
- str += "deadlines = new Deadlines(),";
- str += "delegation = new Delegation(),";
- str += "peopleAssignments = new PeopleAssignments(),";
- str += "names = [ new I18NText( 'en-UK', 'This is my task name')] })";
-
- BlockingAddTaskResponseHandler addTaskResponseHandler = new BlockingAddTaskResponseHandler();
- Task task = ( Task ) eval( new StringReader( str ), vars );
- client.addTask( task, null, addTaskResponseHandler );
- addTaskResponseHandler.waitTillDone(3000);
-
- long taskId = addTaskResponseHandler.getTaskId();
-
- int newPriority = 33;
-
- BlockingTaskOperationResponseHandler setPriorityResponseHandler = new BlockingTaskOperationResponseHandler();
- client.setPriority(taskId, "Darth Vader", newPriority, setPriorityResponseHandler );
- setPriorityResponseHandler.waitTillDone(1000);
- assertFalse( setPriorityResponseHandler.hasError() );
-
- BlockingGetTaskResponseHandler getTaskResponseHandler = new BlockingGetTaskResponseHandler();
- client.getTask( taskId, getTaskResponseHandler );
- Task task1 = getTaskResponseHandler.getTask();
- assertNotSame(task, task1);
- assertFalse( task.equals( task1) );
-
- int newPriority1 = task1.getPriority();
- assertEquals(newPriority, newPriority1);
-
- // Make the same as the returned tasks, so we can test equals
- task.setPriority( newPriority );
- task.getTaskData().setStatus( Status.Created );
- assertEquals(task, task1);
+ TaskServiceTaskAttributesBaseTest.testSetPriority(fillVariables(), client);
}
}
@@ -55,10 +55,7 @@ protected void tearDown() throws Exception {
}
public void testAddRemoveComment() {
- Map vars = new HashMap();
- vars.put("users", users);
- vars.put("groups", groups);
- vars.put("now", new Date());
+ Map<String, Object> vars = fillVariables();
String str = "(with (new Task()) { priority = 55, taskData = (with( new TaskData()) { createdOn = now, activationTime = now}), ";
str += "deadlines = new Deadlines(),";
@@ -136,10 +133,7 @@ public void testAddRemoveComment() {
}
public void testAddRemoveAttachment() throws Exception {
- Map vars = new HashMap();
- vars.put("users", users);
- vars.put("groups", groups);
- vars.put("now", new Date());
+ Map<String, Object> vars = fillVariables();
String str = "(with (new Task()) { priority = 55, taskData = (with( new TaskData()) { createdOn = now, activationTime = now}), ";
str += "deadlines = new Deadlines(),";
@@ -17,8 +17,6 @@
package org.jbpm.task.service.base.async;
import java.io.StringReader;
-import java.util.Date;
-import java.util.HashMap;
import java.util.Map;
import org.jbpm.task.AccessType;
@@ -30,6 +28,7 @@
import org.jbpm.task.service.ContentData;
import org.jbpm.task.service.FaultData;
import org.jbpm.task.service.TaskServer;
+import org.jbpm.task.service.TaskServiceTaskAttributesBaseTest;
import org.jbpm.task.service.responsehandlers.BlockingAddTaskResponseHandler;
import org.jbpm.task.service.responsehandlers.BlockingGetContentResponseHandler;
import org.jbpm.task.service.responsehandlers.BlockingGetTaskResponseHandler;
@@ -51,10 +50,7 @@ protected void tearDown() throws Exception {
}
public void testAddRemoveOutput() {
- Map vars = new HashMap();
- vars.put( "users", users );
- vars.put( "groups", groups );
- vars.put( "now", new Date() );
+ Map<String, Object> vars = fillVariables();
String str = "(with (new Task()) { priority = 55, taskData = (with( new TaskData()) { createdOn = now, activationTime = now,";
str += "actualOwner = new User('Darth Vader')}),";
@@ -116,10 +112,7 @@ public void testAddRemoveOutput() {
}
public void testAddRemoveFault() throws Exception {
- Map vars = new HashMap();
- vars.put( "users", users );
- vars.put( "groups", groups );
- vars.put( "now", new Date() );
+ Map<String, Object> vars = fillVariables();
String str = "(with (new Task()) { priority = 55, taskData = (with( new TaskData()) { createdOn = now, activationTime = now,";
str += "actualOwner = new User('Darth Vader')}),";
@@ -184,43 +177,7 @@ public void testAddRemoveFault() throws Exception {
}
public void testSetPriority() throws Exception {
- Map vars = new HashMap();
- vars.put( "users", users );
- vars.put( "groups", groups );
- vars.put( "now", new Date() );
-
- String str = "(with (new Task()) { priority = 55, taskData = (with( new TaskData()) { createdOn = now, activationTime = now,";
- str += "actualOwner = new User('Darth Vader')}),";
- str += "deadlines = new Deadlines(),";
- str += "delegation = new Delegation(),";
- str += "peopleAssignments = new PeopleAssignments(),";
- str += "names = [ new I18NText( 'en-UK', 'This is my task name')] })";
-
- BlockingAddTaskResponseHandler addTaskResponseHandler = new BlockingAddTaskResponseHandler();
- Task task = ( Task ) eval( new StringReader( str ), vars );
- client.addTask( task, null, addTaskResponseHandler );
-
- long taskId = addTaskResponseHandler.getTaskId();
-
- int newPriority = 33;
-
- BlockingTaskOperationResponseHandler setPriorityResponseHandler = new BlockingTaskOperationResponseHandler();
- client.setPriority(taskId, "Darth Vader", newPriority, setPriorityResponseHandler );
- setPriorityResponseHandler.waitTillDone(1000);
- assertFalse( setPriorityResponseHandler.hasError() );
-
- BlockingGetTaskResponseHandler getTaskResponseHandler = new BlockingGetTaskResponseHandler();
- client.getTask( taskId, getTaskResponseHandler );
- Task task1 = getTaskResponseHandler.getTask();
- assertNotSame(task, task1);
- assertFalse( task.equals( task1) );
-
- int newPriority1 = task1.getPriority();
- assertEquals(newPriority, newPriority1);
-
- // Make the same as the returned tasks, so we can test equals
- task.setPriority( newPriority );
- task.getTaskData().setStatus( Status.Created );
- assertEquals(task, task1);
+ TaskServiceTaskAttributesBaseTest.testSetPriority(fillVariables(), client);
}
+
}
@@ -1,28 +1,20 @@
package org.jbpm.task.service.test;
-import org.drools.SystemEventListenerFactory;
+import static org.jbpm.task.service.test.impl.TestServerUtil.*;
+
import org.jbpm.task.service.TaskClient;
import org.jbpm.task.service.TaskServiceTaskAttributesBaseUserGroupCallbackTest;
-import org.jbpm.task.service.hornetq.HornetQTaskClientConnector;
-import org.jbpm.task.service.hornetq.HornetQTaskClientHandler;
-import org.jbpm.task.service.hornetq.HornetQTaskServer;
+import org.jbpm.task.service.test.impl.TestTaskServer;
public class TaskServiceTaskAttributesUserGroupCallbackTest extends TaskServiceTaskAttributesBaseUserGroupCallbackTest {
@Override
protected void setUp() throws Exception {
super.setUp();
- server = new HornetQTaskServer(taskService, 5446);
- Thread thread = new Thread(server);
- thread.start();
- System.out.println("Waiting for the HornetQTask Server to come up");
- while (!server.isRunning()) {
- System.out.print(".");
- Thread.sleep( 50 );
- }
+
+ server = startServer(taskService);
- client = new TaskClient(new HornetQTaskClientConnector("client 1",
- new HornetQTaskClientHandler(SystemEventListenerFactory.getSystemEventListener())));
- client.connect("127.0.0.1", 5446);
+ client = new TaskClient(createTestTaskClientConnector("client 1", (TestTaskServer) server));
+ client.connect();
}
protected void tearDown() throws Exception {
@@ -36,7 +36,7 @@
protected void setUp() throws Exception {
super.setUp();
- server = startServer(taskService, clientCount);
+ server = startAsyncServer(taskService, clientCount);
}
protected void tearDown() throws Exception {
@@ -36,7 +36,7 @@ protected void setUp() throws Exception {
setEmailHost(props.getProperty("host", "locahost"));
setEmailPort(props.getProperty("port", "2345"));
- server = startServer(taskService);
+ server = startAsyncServer(taskService);
client = new TaskClient(createTestTaskClientConnector("client 1", (TestTaskServer) server));
client.connect();
@@ -21,16 +21,14 @@
import org.jbpm.task.service.TaskClient;
import org.jbpm.task.service.base.async.TaskServiceBaseAsyncTest;
import org.jbpm.task.service.test.impl.TestTaskServer;
-import org.junit.Ignore;
-@Ignore
-public class TaskServiceHornetQAsyncTest extends TaskServiceBaseAsyncTest {
+public class TaskServiceAsyncTest extends TaskServiceBaseAsyncTest {
@Override
protected void setUp() throws Exception {
super.setUp();
- server = startServer(taskService);
+ server = startAsyncServer(taskService);
client = new TaskClient(createTestTaskClientConnector("client 1", (TestTaskServer) server));
client.connect();
@@ -21,16 +21,14 @@
import org.jbpm.task.service.TaskClient;
import org.jbpm.task.service.base.async.TaskServiceCommentsAndAttachmentsBaseAsyncTest;
import org.jbpm.task.service.test.impl.TestTaskServer;
-import org.junit.Ignore;
-@Ignore
-public class TaskServiceCommentsAndAttachmentsHornetQAsyncTest extends TaskServiceCommentsAndAttachmentsBaseAsyncTest {
+public class TaskServiceCommentsAndAttachmentsAsyncTest extends TaskServiceCommentsAndAttachmentsBaseAsyncTest {
@Override
protected void setUp() throws Exception {
super.setUp();
- server = startServer(taskService);
+ server = startAsyncServer(taskService);
client = new TaskClient(createTestTaskClientConnector("client 1", (TestTaskServer) server));
client.connect();
@@ -23,11 +23,9 @@
import org.jbpm.task.service.TaskClient;
import org.jbpm.task.service.base.async.TaskServiceDeadlinesBaseAsyncTest;
import org.jbpm.task.service.test.impl.TestTaskServer;
-import org.junit.Ignore;
import org.subethamail.wiser.Wiser;
-@Ignore
-public class TaskServiceDeadlinesHornetQAsyncTest extends TaskServiceDeadlinesBaseAsyncTest {
+public class TaskServiceDeadlinesAsyncTest extends TaskServiceDeadlinesBaseAsyncTest {
@Override
protected void setUp() throws Exception {
@@ -40,7 +38,7 @@ protected void setUp() throws Exception {
getConf().setProperty("replyTo", "replyTo@domain.com");
getConf().setProperty("defaultLanguage", "en-UK");
- server = startServer(taskService);
+ server = startAsyncServer(taskService);
client = new TaskClient(createTestTaskClientConnector("client 1", (TestTaskServer) server));
client.connect();
Oops, something went wrong.

0 comments on commit 4ad2e93

Please sign in to comment.