Skip to content
This repository has been archived by the owner on Oct 18, 2018. It is now read-only.

Commit

Permalink
Merge pull request #57 from mozilla-services/marina/bug-724200
Browse files Browse the repository at this point in the history
Bug 724200 - SyncStorageRequest.delete() results in NullPointerException. r=rnewman
  • Loading branch information
rnewman committed Feb 7, 2012
2 parents 36cc62c + 0a38f87 commit 3133b2a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
Expand Up @@ -170,6 +170,9 @@ public void addHeaders(HttpRequestBase request, DefaultHttpClient client) {
if (ifUnmodifiedSince != null) {
request.setHeader("x-weave-if-unmodified-since", ifUnmodifiedSince);
}
if (request.getMethod().equalsIgnoreCase("DELETE")) {
request.addHeader("x-confirm-delete", "1");
}
}
}

Expand All @@ -192,7 +195,6 @@ public void get() {
}

public void delete() {
this.resource.request.addHeader("x-confirm-delete", "1");
this.resource.delete();
}

Expand Down
Expand Up @@ -220,4 +220,25 @@ public void testHeadersResponse() throws URISyntaxException {
r.post(new JSONObject());
// Server is stopped in the callback.
}

public class DeleteMockServer extends MockServer {
@Override
public void handle(Request request, Response response) {
assertTrue(request.contains("x-confirm-delete"));
assertEquals("1", request.getValue("x-confirm-delete"));
super.handle(request, response);
}
}

@Test
public void testDelete() throws URISyntaxException {
BaseResource.rewriteLocalhost = false;
data.startHTTPServer(new DeleteMockServer());
SyncStorageRecordRequest r = new SyncStorageRecordRequest(new URI(LOCAL_META_URL)); // URL re-used -- we need any successful response
TestSyncStorageRequestDelegate delegate = new TestSyncStorageRequestDelegate();
delegate._credentials = USER_PASS;
r.delegate = delegate;
r.delete();
// Server is stopped in the callback.
}
}

0 comments on commit 3133b2a

Please sign in to comment.