Author: mircea.markus
Date: 2009-02-17 10:24:59 -0500 (Tue, 17 Feb 2009)
New Revision: 7700
Added:
core/branches/flat/src/test/java/org/horizon/test/ViewChangeListener.java
Modified:
core/branches/flat/src/test/java/org/horizon/loader/decorators/SingletonStoreTest.java
Log:
make tests compilable
Modified:
core/branches/flat/src/test/java/org/horizon/loader/decorators/SingletonStoreTest.java
===================================================================
---
core/branches/flat/src/test/java/org/horizon/loader/decorators/SingletonStoreTest.java 2009-02-17
14:38:40 UTC (rev 7699)
+++
core/branches/flat/src/test/java/org/horizon/loader/decorators/SingletonStoreTest.java 2009-02-17
15:24:59 UTC (rev 7700)
@@ -11,7 +11,7 @@
import org.horizon.loader.dummy.DummyInMemoryCacheLoader;
import org.horizon.manager.CacheManager;
import org.horizon.test.TestingUtil;
-import org.horizon.util.internals.ViewChangeListener;
+import org.horizon.test.ViewChangeListener;
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.fail;
import org.testng.annotations.AfterMethod;
Added: core/branches/flat/src/test/java/org/horizon/test/ViewChangeListener.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/test/ViewChangeListener.java
(rev 0)
+++ core/branches/flat/src/test/java/org/horizon/test/ViewChangeListener.java 2009-02-17
15:24:59 UTC (rev 7700)
@@ -0,0 +1,45 @@
+package org.horizon.test;
+
+import org.horizon.Cache;
+import org.horizon.manager.CacheManager;
+import org.horizon.notifications.Listener;
+import org.horizon.notifications.cachemanagerlistener.annotation.ViewChanged;
+import org.horizon.notifications.cachemanagerlistener.event.ViewChangedEvent;
+
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Listens for view changes. Note that you do NOT have to register this listener; it
does so automatically when
+ * constructed.
+ */
+@Listener
+public class ViewChangeListener {
+ CacheManager cm;
+ final CountDownLatch latch = new CountDownLatch(1);
+
+ public ViewChangeListener(Cache c) {
+ this(c.getCacheManager());
+ }
+
+ public ViewChangeListener(CacheManager cm) {
+ this.cm = cm;
+ cm.addListener(this);
+ }
+
+ @ViewChanged
+ public void onViewChange(ViewChangedEvent e) {
+ latch.countDown();
+ }
+
+ /**
+ * Blocks for a certain amount of time until a view change is received. Note that
this class will start listening
+ * for the view change the moment it is constructed.
+ *
+ * @param time time to wait
+ * @param unit time unit
+ */
+ public void waitForViewChange(long time, TimeUnit unit) throws InterruptedException {
+ if (!latch.await(time, unit)) assert false : "View change not seen after
" + time + " " + unit;
+ }
+}
Property changes on:
core/branches/flat/src/test/java/org/horizon/test/ViewChangeListener.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Show replies by date