1 15 package org.apache.tapestry.services.impl; 16 17 import org.apache.hivemind.Location; 18 import org.apache.hivemind.internal.Module; 19 import org.apache.hivemind.schema.Translator; 20 import org.apache.hivemind.test.HiveMindTestCase; 21 import org.easymock.MockControl; 22 23 30 public class TestDeferredObjectTranslator extends HiveMindTestCase 31 { 32 private Module newModule() 33 { 34 return (Module) newMock(Module.class); 35 } 36 37 private Translator newTranslator(Module module, String objectReference, Location location, 38 Object result) 39 { 40 MockControl control = newControl(Translator.class); 41 Translator translator = (Translator) control.getMock(); 42 43 translator.translate(module, Object .class, objectReference, location); 44 control.setReturnValue(result); 45 46 return translator; 47 } 48 49 public void testDeferredObject() 50 { 51 Object object = new Object (); 52 Module module = newModule(); 53 Location l = newLocation(); 54 Translator translator = newTranslator(module, "OBJ-REFERENCE", l, object); 55 56 replayControls(); 57 58 DeferredObject deferred = new DeferredObjectImpl(translator, module, "OBJ-REFERENCE", l); 59 60 assertSame(object, deferred.getObject()); 61 62 64 assertSame(object, deferred.getObject()); 65 66 verifyControls(); 67 68 assertSame(l, deferred.getLocation()); 69 } 70 71 public void testDeferredObjectTranslator() 72 { 73 Object object = new Object (); 74 Module module = newModule(); 75 Location l = newLocation(); 76 Translator objectTranslator = newTranslator(module, "OBJ-REFERENCE", l, object); 77 78 replayControls(); 79 80 DeferredObjectTranslator translator = new DeferredObjectTranslator(); 81 translator.setObjectTranslator(objectTranslator); 82 83 DeferredObject deferred = (DeferredObject) translator.translate( 84 module, 85 Object .class, 86 "OBJ-REFERENCE", 87 l); 88 89 assertSame(object, deferred.getObject()); 90 91 93 assertSame(object, deferred.getObject()); 94 95 verifyControls(); 96 97 assertSame(l, deferred.getLocation()); 98 } 99 } | Popular Tags |