diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2013-06-17 07:27:01 +0200 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2013-06-17 07:27:01 +0200 |
commit | 86cf88c47df876824f273e9e2671c9fc561c69aa (patch) | |
tree | c721651dcb5d473c5e855d93b4f594004468e0f2 /src/test/java | |
parent | e57f313713ee0fc52d7dd1247c51914d1462dfc2 (diff) | |
download | quartz-based-queue-86cf88c47df876824f273e9e2671c9fc561c69aa.tar.gz quartz-based-queue-86cf88c47df876824f273e9e2671c9fc561c69aa.tar.bz2 quartz-based-queue-86cf88c47df876824f273e9e2671c9fc561c69aa.tar.xz quartz-based-queue-86cf88c47df876824f273e9e2671c9fc561c69aa.zip |
wip
Diffstat (limited to 'src/test/java')
-rw-r--r-- | src/test/java/io/trygvis/test/spring/PlainSpringTest.java | 43 |
1 files changed, 29 insertions, 14 deletions
diff --git a/src/test/java/io/trygvis/test/spring/PlainSpringTest.java b/src/test/java/io/trygvis/test/spring/PlainSpringTest.java index 38d3361..cde0c97 100644 --- a/src/test/java/io/trygvis/test/spring/PlainSpringTest.java +++ b/src/test/java/io/trygvis/test/spring/PlainSpringTest.java @@ -13,6 +13,7 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import java.sql.SQLException; +import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.concurrent.atomic.AtomicReference; @@ -45,31 +46,45 @@ public class PlainSpringTest { @Test public void testBasic() throws SQLException, InterruptedException { - QueueExecutor test = queueService.getQueue("test", 10, true); - final AtomicReference<List<String>> ref = new AtomicReference<>(); - asyncService.registerQueue(test.queue, req, new TaskEffect() { + QueueExecutor queueA = queueService.getQueue("a", 1000, true); +// final AtomicReference<List<String>> refA = new AtomicReference<>(); + asyncService.registerQueue(queueA.queue, req, new TaskEffect() { @Override public List<Task> apply(Task task) throws Exception { - System.out.println("PlainSpringTest.run"); - ref.set(task.arguments); - synchronized (ref) { - ref.notify(); +// refA.set(task.arguments); +// synchronized (refA) { +// refA.notify(); +// } + System.out.println("task.arguments = " + task.arguments); + return asList(task.childTask("b", new Date(), task.arguments.get(0), "world")); + } + }); + + QueueExecutor queueB = queueService.getQueue("b", 1000, true); + final AtomicReference<List<String>> refB = new AtomicReference<>(); + asyncService.registerQueue(queueB.queue, req, new TaskEffect() { + @Override + public List<Task> apply(Task task) throws Exception { +// System.out.println("task.arguments = " + task.arguments); + refB.set(task.arguments); + synchronized (refB) { + refB.notify(); } return emptyList(); } }); - synchronized (ref) { + synchronized (refB) { System.out.println("Scheduling task"); - queueService.schedule(test.queue, new Date(), asList("hello", "world")); + queueService.schedule(queueA.queue, new Date(), asList("hello")); System.out.println("Task scheduled, waiting"); - ref.wait(1000); + refB.wait(10000); System.out.println("Back!"); } - List<String> args = ref.get(); - System.out.println("args = " + args); - assertNotNull(args); - assertThat(args).containsExactly("hello", "world"); +// System.out.println("refA.get() = " + refA.get()); + System.out.println("refB.get() = " + refB.get()); + + assertThat(refB.get()).containsExactly("hello", "world"); } } |