views:

207

answers:

1

So, I have a GWT client, which interacts with a Python Google App Engine server. The client makes request to server resources, the server responds in JSON. It is simple, no RPC or anything like that. I am using Eclipse to develop my GWT code.

I have GWTTestCase test that I would like to run. Unfortunately, I have no idea how to actually get the google app engine server running per test. I had the bright idea below of trying to start the app engine server from the command line, but of course this does not work, as Process and ProcessBuilder are not classes that the GWT Dev kit actually contains.

package com.google.gwt.sample.quizzer.client;

import java.io.IOException;
import java.lang.ProcessBuilder;
import java.lang.Process;

import com.google.gwt.junit.client.GWTTestCase;

public class QuizzerTest extends GWTTestCase {

  public String getModuleName() {
    return "com.google.gwt.sample.quizzer.Quizzer";
  }

  public void gwtSetUp(){
    ProcessBuilder pb = new ProcessBuilder("dev_appserver.py", 
                       "--clear_datastore",
                       "--port=9000",
                       "server_python");
    try {
      p = pb.start();
    } catch (IOException e) {
      System.out.println("Something happened when starting the app server!");
  }

  public void gwtTearDown(){ p.destroy(); }

  public void testSimple() {
    //NOTE: do some actual network testing from the GWT client to GAE here 
    assertTrue(true);}
}

I get the following errors when compiling this file:

[ERROR] Line 21: No source code is available for type java.lang.Process; did you forget to inherit a required module?
[ERROR] Line 30: No source code is available for type java.lang.ProcessBuilder; did you forget to inherit a required module?

As you can see below, I basically want it to be the case that per test it:

  1. Starts a datastore-empty instance of my GAE server
  2. runs the test across the network, against this server instance.
  3. Stop the server
  4. Of course, report the result of the test back to me.

Does anyone have a good way of doing this? Partial solutions are welcome! Hacks are fine as well. Maybe some progress on this problem could be made by editing the ".launch" config file? The only important criteria is that I would like to "unit test" portions of my GWT code against my actual GAE Python server.

Thank you.

A: 

I would recommend creating an Ant target for this - take a look at this page for the full ant build file for GWT.

Then, as the first line of the testing target, add an execution task to start the server. Look here for exec docs.

Then set up that ant task in your IDE. This way you get the server running before your tests irrespective of where you run the tests from, and it can be integrated into your build process if you want.

Sudhir Jonathan