@BeforeMethod(alwaysRun = true)
  public void setUp() throws Exception {
    loc = new LocalhostMachineProvisioningLocation();
    app = ApplicationBuilder.newManagedApp(TestApplication.class);
    entity = app.createAndManageChild(EntitySpec.create(TestEntity.class));
    app.start(ImmutableList.of(loc));

    server = BetterMockWebServer.newInstanceLocalhost();
    for (int i = 0; i < 100; i++) {
      server.enqueue(
          new MockResponse()
              .setResponseCode(200)
              .addHeader("content-type: application/json")
              .setBody("{\"foo\":\"myfoo\"}"));
    }
    server.play();
    baseUrl = server.getUrl("/");
  }
 @AfterMethod(alwaysRun = true)
 public void tearDown() throws Exception {
   if (server != null) server.shutdown();
   if (app != null) Entities.destroyAll(app.getManagementContext());
 }