From 9d93ea7a90445886ce92fe5fb4d92877186f1010 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Tue, 21 Jul 2009 00:29:37 +0000 Subject: [PATCH] Nixed our ATUnit dependency which wasn't working. Better that we just do the Guicing we need ourselves. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5884 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- tests/build.xml | 6 ++--- .../threerings/presents/server/DOMTest.java | 13 ++-------- .../presents/server/DestroyedRefTest.java | 24 ++++++------------- .../presents/server/PresentsTestBase.java | 23 ++++++++++++++++++ .../threerings/presents/server/RefTest.java | 13 ++-------- 5 files changed, 37 insertions(+), 42 deletions(-) create mode 100644 tests/src/java/com/threerings/presents/server/PresentsTestBase.java diff --git a/tests/build.xml b/tests/build.xml index 723ac1a29..e602b1d87 100644 --- a/tests/build.xml +++ b/tests/build.xml @@ -163,8 +163,8 @@ - + + @@ -172,7 +172,7 @@ - + diff --git a/tests/src/java/com/threerings/presents/server/DOMTest.java b/tests/src/java/com/threerings/presents/server/DOMTest.java index af805be9d..6a96557ac 100644 --- a/tests/src/java/com/threerings/presents/server/DOMTest.java +++ b/tests/src/java/com/threerings/presents/server/DOMTest.java @@ -22,13 +22,6 @@ package com.threerings.presents.server; import org.junit.Test; -import org.junit.runner.RunWith; - -import atunit.AtUnit; -import atunit.Container; -import atunit.Unit; - -import com.google.inject.Inject; import com.threerings.presents.data.TestObject; import com.threerings.presents.dobj.AttributeChangeListener; @@ -41,9 +34,7 @@ import static org.junit.Assert.assertTrue; /** * A simple test case for the dobjmgr. */ -@RunWith(AtUnit.class) -@Container(Container.Option.GUICE) -public class DOMTest +public class DOMTest extends PresentsTestBase implements AttributeChangeListener, ElementUpdateListener { @Test public void runTest () @@ -106,5 +97,5 @@ public class DOMTest // the values we'll receive via attribute changed events protected Object[] values = { new Integer(99), "hoopie", new Integer(25), "howdy" }; - @Inject @Unit protected PresentsDObjectMgr _omgr; + protected PresentsDObjectMgr _omgr = getInstance(PresentsDObjectMgr.class); } diff --git a/tests/src/java/com/threerings/presents/server/DestroyedRefTest.java b/tests/src/java/com/threerings/presents/server/DestroyedRefTest.java index 40f349992..f79628c48 100644 --- a/tests/src/java/com/threerings/presents/server/DestroyedRefTest.java +++ b/tests/src/java/com/threerings/presents/server/DestroyedRefTest.java @@ -22,13 +22,6 @@ package com.threerings.presents.server; import org.junit.Test; -import org.junit.runner.RunWith; - -import atunit.AtUnit; -import atunit.Container; -import atunit.Unit; - -import com.google.inject.Inject; import com.threerings.presents.data.TestObject; import com.threerings.presents.dobj.AttributeChangedEvent; @@ -37,17 +30,15 @@ import com.threerings.presents.dobj.EventListener; import com.threerings.presents.dobj.ObjectAddedEvent; import com.threerings.presents.dobj.ObjectDestroyedEvent; -import static com.threerings.presents.Log.log; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; +import static com.threerings.presents.Log.log; + /** - * Tests that the dobjmgr will not allow a destroyed object to be added to - * an oid list. + * Tests that the dobjmgr will not allow a destroyed object to be added to an oid list. */ -@RunWith(AtUnit.class) -@Container(Container.Option.GUICE) -public class DestroyedRefTest +public class DestroyedRefTest extends PresentsTestBase { @Test public void runTest () { @@ -63,9 +54,8 @@ public class DestroyedRefTest log.info("The following addToList() should be ignored."); _objtwo.addToList(_objone.getOid()); - // now that we have both objects, try to set up the reference. first - // we queue up a destroy event for object two, then we try to reference - // it on object one's oid list + // now that we have both objects, try to set up the reference. first we queue up a destroy + // event for object two, then we try to reference it on object one's oid list _objtwo.destroy(); _objone.addToList(_objtwo.getOid()); @@ -101,5 +91,5 @@ public class DestroyedRefTest protected TestObject _objone, _objtwo; - @Inject @Unit protected PresentsDObjectMgr _omgr; + protected PresentsDObjectMgr _omgr = getInstance(PresentsDObjectMgr.class); } diff --git a/tests/src/java/com/threerings/presents/server/PresentsTestBase.java b/tests/src/java/com/threerings/presents/server/PresentsTestBase.java new file mode 100644 index 000000000..99cab1c9b --- /dev/null +++ b/tests/src/java/com/threerings/presents/server/PresentsTestBase.java @@ -0,0 +1,23 @@ +// +// $Id$ + +package com.threerings.presents.server; + +import com.google.inject.Guice; +import com.google.inject.Injector; + +/** + * Sets up Guice so that presents things can be tested. + */ +public class PresentsTestBase +{ + protected T getInstance (Class clazz) + { + if (_injector == null) { + _injector = Guice.createInjector(new PresentsServer.Module()); + } + return _injector.getInstance(clazz); + } + + protected Injector _injector; +} diff --git a/tests/src/java/com/threerings/presents/server/RefTest.java b/tests/src/java/com/threerings/presents/server/RefTest.java index 146a2ca8a..483635682 100644 --- a/tests/src/java/com/threerings/presents/server/RefTest.java +++ b/tests/src/java/com/threerings/presents/server/RefTest.java @@ -22,13 +22,6 @@ package com.threerings.presents.server; import org.junit.Test; -import org.junit.runner.RunWith; - -import atunit.AtUnit; -import atunit.Container; -import atunit.Unit; - -import com.google.inject.Inject; import com.threerings.presents.data.TestObject; import com.threerings.presents.dobj.DEvent; @@ -42,9 +35,7 @@ import static org.junit.Assert.assertTrue; /** * Tests the oid list reference tracking code. */ -@RunWith(AtUnit.class) -@Container(Container.Option.GUICE) -public class RefTest +public class RefTest extends PresentsTest { @Test public void runTest () { @@ -96,5 +87,5 @@ public class RefTest protected TestObject _objone; protected TestObject _objtwo; - @Inject @Unit protected PresentsDObjectMgr _omgr; + protected PresentsDObjectMgr _omgr = getInstance(PresentsDObjectMgr.class); }