@Test public void testBasicSetup() { // build injector, but don't make use of it directly, only via the request processor Injector i = Guice.createInjector(new TestModule()); SampleFactory f = RequestFactorySource.create(SampleFactory.class); // final String[] holder = new String[1]; final AtomicReference<String> holder = new AtomicReference<String>(); f.initialize( new SimpleEventBus(), new RequestTransport() { public void send(String arg0, TransportReceiver arg1) { // the SIMPLE_REQUEST_PROCESSOR field should have been repopulated by guice // and any dependencies satisfied String resp = GwtRequestFactoryVisitor.SIMPLE_REQUEST_PROCESSOR.process(arg0); arg1.onTransportSuccess(resp); } }); f.req() .trim(" word ") .fire( new Receiver<String>() { @Override public void onSuccess(String arg0) { holder.set(arg0); } }); Assert.assertEquals("word", holder.get()); }
public static SocialwindRequestFactory get() { ServiceLayer serviceLayer = ServiceLayer.create(); SimpleRequestProcessor requestProcessor = new SimpleRequestProcessor(serviceLayer); EventBus eventBus = new SimpleEventBus(); SocialwindRequestFactory swrf = RequestFactorySource.create(SocialwindRequestFactory.class); swrf.initialize(eventBus, new InProcessRequestTransport(requestProcessor)); return swrf; }