Examples of FakeResponse


Examples of foo.domaintest.util.testutil.FakeResponse

  @Rule public TestEnvironment env = new TestEnvironment(new LocalMemcacheServiceTestConfig());

  public StashActionTest() {
    action.memcache = memcache;
    action.lazyRandomToken = lazy("token");
    action.response = new FakeResponse();
    action.tempUrlFactory = new TempUrlFactory(TESTING_URL_BASE + "/stash");
  }
View Full Code Here

Examples of foo.domaintest.util.testutil.FakeResponse

  }

  void runServletVerifyCaching(Map<String, Object> expectedParams) throws Exception {
    action.run();
    assertEquals(
        new FakeResponse().setPayload(TESTING_URL_BASE + "/temp/token"),
        action.response);
    assertTrue(((FakeResponse) action.response).isResponseSent());
    assertEquals(expectedParams, memcache.load(new Key(STASH, "token")));
  }
View Full Code Here

Examples of foo.domaintest.util.testutil.FakeResponse

    action.cookiesToAdd = ImmutableMap.of("j", "k", "m", "");
    action.headers = ImmutableMap.of("aa", "bb", "cc", "");
    action.payload = "foo";
    action.run();
    assertEquals(
        new FakeResponse().setPayload(TESTING_URL_BASE + "/temp/token"),
        action.response);
    assertTrue(((FakeResponse) action.response).isResponseSent());
    assertEquals(
        new ImmutableMap.Builder<String, Object>()
            .put("status", action.status)
View Full Code Here

Examples of foo.domaintest.util.testutil.FakeResponse

  @Test
  public void testNoneSet() {
    action.run();
    assertEquals(
        new FakeResponse().setPayload(TESTING_URL_BASE + "/temp/token"),
        action.response);
    assertTrue(((FakeResponse) action.response).isResponseSent());
    Map<String, Object> expected = new HashMap<>();
    expected.put("status", null);
    expected.put("sleepSeconds", null);
View Full Code Here

Examples of foo.domaintest.util.testutil.FakeResponse

    action.requestPath = "http://testing.example/temp/token";
  }

  @Test
  public void testTemp() {
    action.response = new FakeResponse();
    memcache.save(
        new Key(STASH, "token"),
        new ImmutableMap.Builder<String, Object>()
            .put("status", 234)
            .put("sleepSeconds", 5)
            .put("mimeType", "a/b")
            .put("cookiesToDelete", ImmutableList.of("x", "y"))
            .put("cookiesToAdd", ImmutableMap.of("j", "k", "m", ""))
            .put("headers", ImmutableMap.of("aa", "bb", "cc", ""))
            .put("payload", "foo")
            .build(),
        null);
    action.run();
    assertEquals(
        new FakeResponse()
            .setStatus(234)
            .setSleepSeconds(5)
            .setMimeType("a/b")
            .setCookiesToDelete(ImmutableList.of("x", "y"))
            .setCookiesToAdd(ImmutableMap.of("j", "k", "m", ""))
View Full Code Here

Examples of foo.domaintest.util.testutil.FakeResponse

  EchoAction action  = new EchoAction();

  @Test
  public void testEcho() {
    action.response = new FakeResponse();
    action.status = 234;
    action.sleepSeconds = 5;
    action.mimeType = "a/b";
    action.cookiesToDelete = ImmutableList.of("x", "y");
    action.cookiesToAdd = ImmutableMap.of("j", "k", "m", "");
    action.headers = ImmutableMap.of("aa", "bb", "cc", "");
    action.payload = "foo";
    action.run();
    assertEquals(
        new FakeResponse()
            .setStatus(234)
            .setSleepSeconds(5)
            .setMimeType("a/b")
            .setCookiesToDelete(ImmutableList.of("x", "y"))
            .setCookiesToAdd(ImmutableMap.of("j", "k", "m", ""))
View Full Code Here

Examples of foo.domaintest.util.testutil.FakeResponse

  @Test
  public void testSavesAndReturnsToken() {
    TokenAction action = new TokenAction();
    action.memcache = new Memcache(null, mock(Metrics.class));
    action.response = new FakeResponse();
    action.randomToken = "token";
    action.run();
    assertEquals(
        new FakeResponse().setPayload("token"),
        action.response);
    assertTrue(((FakeResponse) action.response).isResponseSent());
    assertTrue((boolean) action.memcache.load(new Key(TOKEN, "token")));
  }
View Full Code Here

Examples of hirondelle.fish.test.doubles.FakeResponse

    testEditActionFails("Name=Carol&IsActive=true&Disposition=1", ADD); //duplicate name
  }
 
  public void testList() throws AppException {
    HttpServletRequest req = FakeRequest.forGET(LIST, NO_PARAMS);
    HttpServletResponse resp = new FakeResponse();
    MemberAction action = new MemberAction(new RequestParserImpl(req, resp));
   
    ResponsePage responsePage = action.execute();
    Object item = req.getAttribute(ITEMS_FOR_LISTING);
    assertTrue(item != null);
View Full Code Here

Examples of hirondelle.fish.test.doubles.FakeResponse

    //log(item);
  }
 
  public void testFetch() throws AppException {
    HttpServletRequest req = FakeRequest.forGET(FETCH, "Id=3");
    HttpServletResponse resp = new FakeResponse();
    MemberAction action = new MemberAction(new RequestParserImpl(req, resp));
   
    ResponsePage responsePage = action.execute();
    Object item = req.getAttribute(ITEM_FOR_EDIT);
    //log(item);
View Full Code Here

Examples of hirondelle.fish.test.doubles.FakeResponse

      req = FakeRequest.forGET(aServletPath, aQueryString);
    }
    HttpSession session = req.getSession(true); //links request to session
    assertTrue(session != null);
   
    HttpServletResponse resp = new FakeResponse();
    MemberAction action = new MemberAction(new RequestParserImpl(req, resp));
   
    if(aSucceeds) {
      assertActionSucceeds(req, action);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.