diff --git a/core/src/test/java/google/registry/server/RegistryTestServerMain.java b/core/src/test/java/google/registry/server/RegistryTestServerMain.java index de9f55f61..f31038811 100644 --- a/core/src/test/java/google/registry/server/RegistryTestServerMain.java +++ b/core/src/test/java/google/registry/server/RegistryTestServerMain.java @@ -19,6 +19,7 @@ import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameters; import com.google.common.collect.ImmutableList; import com.google.common.net.HostAndPort; +import google.registry.model.transaction.JpaTransactionManagerRule; import google.registry.testing.AppEngineRule; import google.registry.testing.UserInfo; import google.registry.tools.params.HostAndPortParameter; @@ -134,36 +135,44 @@ public final class RegistryTestServerMain { LIGHT_PURPLE, ORANGE, PINK, RESET); final RegistryTestServer server = new RegistryTestServer(address); - Statement runner = new Statement() { - @Override - public void evaluate() throws InterruptedException { - System.out.printf("%sLoading Datastore fixtures...%s\n", BLUE, RESET); - for (Fixture fixture : fixtures) { - fixture.load(); - } - System.out.printf("%sStarting Jetty6 HTTP Server...%s\n", BLUE, RESET); - server.start(); - System.out.printf("%sListening on: %s%s\n", PURPLE, server.getUrl("/"), RESET); - try { - while (true) { - server.process(); + Statement runner = + new Statement() { + @Override + public void evaluate() throws InterruptedException { + System.out.printf("%sLoading Datastore fixtures...%s\n", BLUE, RESET); + for (Fixture fixture : fixtures) { + fixture.load(); + } + System.out.printf("%sStarting Jetty6 HTTP Server...%s\n", BLUE, RESET); + server.start(); + System.out.printf("%sListening on: %s%s\n", PURPLE, server.getUrl("/"), RESET); + try { + while (true) { + server.process(); + } + } finally { + server.stop(); + } } - } finally { - server.stop(); - } - }}; + }; - System.out.printf("%sLoading AppEngineRule...%s\n", BLUE, RESET); - AppEngineRule.builder() - .withDatastore() - .withUrlFetch() - .withTaskQueue() - .withLocalModules() - .withUserService(loginIsAdmin - ? UserInfo.createAdmin(loginEmail, loginUserId) - : UserInfo.create(loginEmail, loginUserId)) + Statement withAppEngine = + AppEngineRule.builder() + .withDatastore() + .withUrlFetch() + .withTaskQueue() + .withLocalModules() + .withUserService( + loginIsAdmin + ? UserInfo.createAdmin(loginEmail, loginUserId) + : UserInfo.create(loginEmail, loginUserId)) + .build() + .apply(runner, Description.EMPTY); + + System.out.printf("%sLoading SQL fixtures and AppEngineRule...%s\n", BLUE, RESET); + new JpaTransactionManagerRule.Builder() .build() - .apply(runner, Description.EMPTY) + .apply(withAppEngine, Description.EMPTY) .evaluate(); } diff --git a/core/src/test/java/google/registry/webdriver/TestServerRule.java b/core/src/test/java/google/registry/webdriver/TestServerRule.java index 2ab547225..9c33319c6 100644 --- a/core/src/test/java/google/registry/webdriver/TestServerRule.java +++ b/core/src/test/java/google/registry/webdriver/TestServerRule.java @@ -23,6 +23,7 @@ import static google.registry.util.NetworkUtils.pickUnusedPort; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.net.HostAndPort; +import google.registry.model.transaction.JpaTransactionManagerRule; import google.registry.request.auth.AuthenticatedRegistrarAccessor; import google.registry.server.Fixture; import google.registry.server.Route; @@ -53,6 +54,7 @@ public final class TestServerRule extends ExternalResource { private final ImmutableList fixtures; private final AppEngineRule appEngineRule; + private final JpaTransactionManagerRule jpaTransactionManagerRule; private final BlockingQueue> jobs = new LinkedBlockingDeque<>(); private final ImmutableMap runfiles; private final ImmutableList routes; @@ -80,6 +82,7 @@ public final class TestServerRule extends ExternalResource { .withTaskQueue() .withUserService(UserInfo.createAdmin(email, THE_REGISTRAR_GAE_USER_ID)) .build(); + this.jpaTransactionManagerRule = new JpaTransactionManagerRule.Builder().build(); } @Override @@ -164,9 +167,8 @@ public final class TestServerRule extends ExternalResource { @Override public void run() { try { - appEngineRule - .apply(this, Description.EMPTY) - .evaluate(); + Statement appEngineStatement = appEngineRule.apply(this, Description.EMPTY); + jpaTransactionManagerRule.apply(appEngineStatement, Description.EMPTY).evaluate(); } catch (InterruptedException e) { // This is what we expect to happen. } catch (Throwable e) {