Dispatcher { protected Reference storeObject(String objectName, Object object) { if (object == null) { return null; } Class<?> klass = object.getClass(); serviceToClass.put(object, klass); services.put(objectName, object); return Reference.createClientReference(bridge, objectName, Utils.getMethods(klass)); } protected  Dispatcher(Bridge bridge); Reference storeRandomObject(Object object);  }
@Test public void testStoreObject() { BridgeObject service2 = new BridgeObject() { }; Reference ref2 = dispatcher.storeObject("s2", service2); assertSame(service2, dispatcher.getObject("s2")); assertEquals( ref2, Reference.createClientReference(bridge, "s2", Arrays.asList(new String[] {}))); Reference ref1 = dispatcher.storeObject("s1", service2); assertEquals( ref1, Reference.createClientReference(bridge, "s1", Arrays.asList(new String[] {}))); assertNotSame(bridgeObject, dispatcher.getObject("s1")); assertSame(service2, dispatcher.getObject("s1")); }