From 86cf88c47df876824f273e9e2671c9fc561c69aa Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Mon, 17 Jun 2013 07:27:01 +0200 Subject: wip --- .../io/trygvis/test/spring/PlainSpringTest.java | 43 +++++++++++++++------- 1 file changed, 29 insertions(+), 14 deletions(-) (limited to 'src/test/java/io/trygvis/test/spring/PlainSpringTest.java') 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> ref = new AtomicReference<>(); - asyncService.registerQueue(test.queue, req, new TaskEffect() { + QueueExecutor queueA = queueService.getQueue("a", 1000, true); +// final AtomicReference> refA = new AtomicReference<>(); + asyncService.registerQueue(queueA.queue, req, new TaskEffect() { @Override public List 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> refB = new AtomicReference<>(); + asyncService.registerQueue(queueB.queue, req, new TaskEffect() { + @Override + public List 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 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"); } } -- cgit v1.2.3