@Test public void testFetch_withToken() throws Exception { Uri uri = Uri.parse("http://host?p=1&st=sometoken"); // We should get the request untouched. HttpRequest request = createMock(HttpRequest.class); expect(request.getUri()).andReturn(uri); replay(request); HttpResponse response = new HttpResponse(); HttpFetcher fetcher = createMock(HttpFetcher.class); expect(fetcher.fetch(request)).andReturn(response); replay(fetcher); FakeUserHttpFetcher fakeFetcher; fakeFetcher = new FakeUserHttpFetcher(config, fetcher, crypter); fakeFetcher.fetch(request); verify(request); verify(fetcher); }
@Test public void testFetch_noToken() throws Exception { Uri uri = Uri.parse("http://host?p=1"); HttpRequest request = createMock(HttpRequest.class); expect(request.getUri()).andReturn(uri); expect(request.setUri(Uri.parse("http://host?p=1&st=default%3Anull"))).andReturn(request); replay(request); HttpResponse response = new HttpResponse(); HttpFetcher fetcher = createMock(HttpFetcher.class); expect(fetcher.fetch(request)).andReturn(response); replay(fetcher); FakeUserHttpFetcher fakeFetcher; fakeFetcher = new FakeUserHttpFetcher(config, fetcher, crypter); fakeFetcher.fetch(request); verify(request); verify(fetcher); }