Thursday, January 20, 2011

Re: in process remote service for testing purposes

After pausing and thinking for a few moments I realized this was a
very stupid question. But just in case anyone else gets lost from
"not seeing the forest through the trees" here is my in-process
service for testing purposes.

import com.google.gwt.user.client.rpc.AsyncCallback;
import com.map.hunting.server.CommandExecutorImpl;

/**
/* In-process CommandExecutor service for testing purposes
/*
public class TstCommandExecutor implements CommandExecutorAsync {

private static CommandExecutorImpl inProcServer = new
CommandExecutorImpl();

public static void load() {
Util.load(); // just force the Util class to get loaded.
}

public static class Util extends CommandExecutor.Util {
static {
// changed CommandExecutor.Util.instance from private to
protected.
CommandExecutor.Util.instance = new TstCommandExecutor();
}
public static void load() {
// do nothing we are loaded.
}
}

@Override
public void executeCommand(String marshaledCommand,
AsyncCallback<String> callback) {
try {
String result =
inProcServer.executeCommand(marshaledCommand);
callback.onSuccess(result);
} catch (Throwable caught) {
callback.onFailure(caught);
}
}
}

In my JUnit tests I just make sure I replace the service
implementaion.

@BeforeClass
public static beforeClass() {
TstCommandExecutor.load(); // replace the remote service with
// in-process test version
}

Sorry for cluttering this group but I thought there might be others
might get lost like I did. Also, if there is a simpler solution
I'd be interested.

Jeremy


On Jan 19, 7:32 pm, jeremy rose <jeremy.rosenb...@gmail.com> wrote:
> I had my own command handling implementation that marshals client
> requests via a simple GWT remote service before GWT 2.1.1 was
> available.    After tinkering with RequestFactory for a while, I've
> decided to continue using my exising interface rather than undergo
> extensive refactoring at this time.
>
>         public interface CommandExecutor extends RemoteService {
>         public String executeCommand(String aMarshalledCommand);
>         }
>
> However, there is one feature of GWT 2.1.1 RequestFactory that I
> really really reallly which I had.   Is there any way to instantiate
> my existing RemoteService with a in-processtransport for testing
> purposes.   That is, I want to do something similar to what can be
> achieved with RequestFactoryMagic and an InProcessRequestTransport?
>
> com.google.gwt.requestfactory.server.testing.RequestFactoryMagic
>
> com.google.gwt.requestfactory.server.testing.InProcessRequestTransport
>
> Jeremy

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate