List of usage examples for org.apache.commons.httpclient HttpStatus SC_NO_CONTENT
int SC_NO_CONTENT
To view the source code for org.apache.commons.httpclient HttpStatus SC_NO_CONTENT.
Click Source Link
From source file:muki.tool.JavaCompilationDeploymentTestCase.java
/** * Verifies that a 204 status code is returned when the operation returns null. *//*from w ww .j a v a2 s. c o m*/ @Test public void testPutOperationNull3() throws Exception { String url = URL_RESOURCE2 + "/pathPutOperationNull3"; PutMethod method = new PutMethod(url); int statusCode = this.getHttpClient().executeMethod(method); assertTrue("Method failed: " + method.getStatusLine(), statusCode == HttpStatus.SC_NO_CONTENT); byte[] responseBody = method.getResponseBody(); assertNull(responseBody); }
From source file:muki.tool.JavaCompilationDeploymentTestCase.java
@Test public void testDeleteOperation1() throws Exception { String url = URL_RESOURCE1 + "/pathDeleteOperation1"; DeleteMethod method = new DeleteMethod(url); int statusCode = this.getHttpClient().executeMethod(method); assertTrue("Method failed: " + method.getStatusLine(), statusCode == HttpStatus.SC_NO_CONTENT); byte[] responseBody = method.getResponseBody(); assertNull(responseBody);// w w w. ja v a 2 s . c o m }
From source file:muki.tool.JavaCompilationDeploymentTestCase.java
@Test public void testDeleteOperation2() throws Exception { String url = URL_RESOURCE1 + "/pathDeleteOperation2"; DeleteMethod method = new DeleteMethod(url); int statusCode = this.getHttpClient().executeMethod(method); assertTrue("Method failed: " + method.getStatusLine(), statusCode == HttpStatus.SC_NO_CONTENT); byte[] responseBody = method.getResponseBody(); assertNull(responseBody);/*from www.j a v a 2 s. c o m*/ }
From source file:muki.tool.JavaCompilationDeploymentTestCase.java
@Test public void testDeleteOperation3() throws Exception { String url = URL_RESOURCE1 + "/pathDeleteOperation3"; DeleteMethod method = new DeleteMethod(url); int statusCode = this.getHttpClient().executeMethod(method); assertTrue("Method failed: " + method.getStatusLine(), statusCode == HttpStatus.SC_NO_CONTENT); byte[] responseBody = method.getResponseBody(); assertNull(responseBody);// w w w. ja v a 2s .c o m }
From source file:muki.tool.JavaCompilationDeploymentTestCase.java
@Test public void testDeleteOperation4() throws Exception { String url = URL_RESOURCE1 + "/pathDeleteOperation4/4/5"; DeleteMethod method = new DeleteMethod(url); int statusCode = this.getHttpClient().executeMethod(method); assertTrue("Method failed: " + method.getStatusLine(), statusCode == HttpStatus.SC_NO_CONTENT); byte[] responseBody = method.getResponseBody(); assertNull(responseBody);//from w w w . j av a 2 s . com }
From source file:muki.tool.JavaCompilationDeploymentTestCase.java
@Test public void testDeleteOperation5() throws Exception { String url = URL_RESOURCE1 + "/pathDeleteOperation5/55?date=2010-07-08"; DeleteMethod method = new DeleteMethod(url); int statusCode = this.getHttpClient().executeMethod(method); assertTrue("Method failed: " + method.getStatusLine(), statusCode == HttpStatus.SC_NO_CONTENT); byte[] responseBody = method.getResponseBody(); assertNull(responseBody);//from w ww . j a v a2 s . c o m }
From source file:com.zimbra.qa.unittest.TestCalDav.java
private void attendeeDeleteFromCalendar(boolean suppressReply) throws Exception { Account dav1 = users[1].create();//from w w w . jav a 2 s . c o m users[2].create(); String url = getSchedulingInboxUrl(dav1, dav1); ReportMethod method = new ReportMethod(url); addBasicAuthHeaderForUser(method, dav1); ZMailbox organizer = users[2].getZMailbox(); users[1].getZMailbox(); // Force creation of mailbox - shouldn't be needed String subject = String.format("%s %s", NAME_PREFIX, suppressReply ? "testInvite which shouldNOT be replied to" : "testInvite to be auto-declined"); Date startDate = new Date(System.currentTimeMillis() + Constants.MILLIS_PER_DAY); Date endDate = new Date(startDate.getTime() + Constants.MILLIS_PER_HOUR); TestUtil.createAppointment(organizer, subject, dav1.getName(), startDate, endDate); // Wait for appointment to arrive String href = waitForNewSchedulingRequestByUID(dav1, ""); assertNotNull("href for inbox invitation", href); String uid = href.substring(href.lastIndexOf('/') + 1); uid = uid.substring(0, uid.indexOf(',') - 1); String calFolderUrl = getFolderUrl(dav1, "Calendar"); String delurl = waitForItemInCalendarCollectionByUID(calFolderUrl, dav1, uid, true, 5000); StringBuilder sb = getLocalServerRoot().append(delurl); DeleteMethod delMethod = new DeleteMethod(sb.toString()); addBasicAuthHeaderForUser(delMethod, dav1); if (suppressReply) { delMethod.addRequestHeader(DavProtocol.HEADER_SCHEDULE_REPLY, "F"); } HttpClient client = new HttpClient(); HttpMethodExecutor.execute(client, delMethod, HttpStatus.SC_NO_CONTENT); List<ZMessage> msgs; if (suppressReply) { // timeout may be a bit short but don't want long time wastes in test suite. msgs = TestUtil.waitForMessages(organizer, "is:invite is:unread inid:2 after:\"-1month\"", 0, 2000); if (msgs != null) { assertEquals("Should be no DECLINE reply msg", 0, msgs.size()); } } else { msgs = TestUtil.waitForMessages(organizer, "is:invite is:unread inid:2 after:\"-1month\"", 1, 10000); assertNotNull("inbox DECLINE reply msgs", msgs); assertEquals("Should be 1 DECLINE reply msg", 1, msgs.size()); assertNotNull("inbox DECLINE reply msg invite", msgs.get(0).getInvite()); } }
From source file:com.zimbra.qa.unittest.TestCalDav.java
@Test public void testAppleStyleGroup() throws ServiceException, IOException { Account dav1 = users[1].create();// w ww . j a v a 2 s .c om String contactsFolderUrl = getFolderUrl(dav1, "Contacts"); HttpClient client = new HttpClient(); PostMethod postMethod = new PostMethod(contactsFolderUrl); addBasicAuthHeaderForUser(postMethod, dav1); postMethod.addRequestHeader("Content-Type", "text/vcard"); postMethod .setRequestEntity(new ByteArrayRequestEntity(rachelVcard.getBytes(), MimeConstants.CT_TEXT_VCARD)); HttpMethodExecutor.execute(client, postMethod, HttpStatus.SC_CREATED); postMethod = new PostMethod(contactsFolderUrl); addBasicAuthHeaderForUser(postMethod, dav1); postMethod.addRequestHeader("Content-Type", "text/vcard"); postMethod.setRequestEntity( new ByteArrayRequestEntity(blueGroupCreate.getBytes(), MimeConstants.CT_TEXT_VCARD)); HttpMethodExecutor exe = HttpMethodExecutor.execute(client, postMethod, HttpStatus.SC_CREATED); String groupLocation = null; for (Header hdr : exe.respHeaders) { if ("Location".equals(hdr.getName())) { groupLocation = hdr.getValue(); } } assertNotNull("Location Header returned when creating Group", groupLocation); postMethod = new PostMethod(contactsFolderUrl); addBasicAuthHeaderForUser(postMethod, dav1); postMethod.addRequestHeader("Content-Type", "text/vcard"); postMethod.setRequestEntity(new ByteArrayRequestEntity(parisVcard.getBytes(), MimeConstants.CT_TEXT_VCARD)); HttpMethodExecutor.execute(client, postMethod, HttpStatus.SC_CREATED); String url = String.format("%s%s", contactsFolderUrl, "F53A6F96-566F-46CC-8D48-A5263FAB5E38.vcf"); PutMethod putMethod = new PutMethod(url); addBasicAuthHeaderForUser(putMethod, dav1); putMethod.addRequestHeader("Content-Type", "text/vcard"); putMethod.setRequestEntity( new ByteArrayRequestEntity(blueGroupModify.getBytes(), MimeConstants.CT_TEXT_VCARD)); HttpMethodExecutor.execute(client, putMethod, HttpStatus.SC_NO_CONTENT); GetMethod getMethod = new GetMethod(url); addBasicAuthHeaderForUser(getMethod, dav1); getMethod.addRequestHeader("Content-Type", "text/vcard"); exe = HttpMethodExecutor.execute(client, getMethod, HttpStatus.SC_OK); String respBody = new String(exe.responseBodyBytes, MimeConstants.P_CHARSET_UTF8); String[] expecteds = { "X-ADDRESSBOOKSERVER-KIND:group", "X-ADDRESSBOOKSERVER-MEMBER:urn:uuid:BE43F16D-336E-4C3E-BAE6-22B8F245A986", "X-ADDRESSBOOKSERVER-MEMBER:urn:uuid:07139DE2-EA7B-46CB-A970-C4DF7F72D9AE" }; for (String expected : expecteds) { assertTrue(String.format("GET should contain '%s'\nBODY=%s", expected, respBody), respBody.contains(expected)); } // members are actually stored in a different way. Make sure it isn't a fluke // that the GET response contained the correct members by checking that the members // appear where expected in a search hit. SearchRequest searchRequest = new SearchRequest(); searchRequest.setSortBy("dateDesc"); searchRequest.setLimit(8); searchRequest.setSearchTypes("contact"); searchRequest.setQuery("in:Contacts"); ZMailbox mbox = users[1].getZMailbox(); SearchResponse searchResp = mbox.invokeJaxb(searchRequest); assertNotNull("JAXB SearchResponse object", searchResp); List<SearchHit> hits = searchResp.getSearchHits(); assertNotNull("JAXB SearchResponse hits", hits); assertEquals("JAXB SearchResponse hits", 3, hits.size()); boolean seenGroup = false; for (SearchHit hit : hits) { ContactInfo contactInfo = (ContactInfo) hit; if ("BlueGroup".equals(contactInfo.getFileAs())) { seenGroup = true; assertEquals("Number of members of group in search hit", 2, contactInfo.getContactGroupMembers().size()); } ZimbraLog.test.info("Hit %s class=%s", hit, hit.getClass().getName()); } assertTrue("Seen group", seenGroup); }
From source file:davmail.exchange.ews.EwsExchangeSession.java
@Override public int sendEvent(String icsBody) throws IOException { String itemName = UUID.randomUUID().toString() + ".EML"; byte[] mimeContent = new Event(DRAFTS, itemName, "urn:content-classes:calendarmessage", icsBody, null, null) .createMimeContent();/*from w w w . j a v a 2 s . c om*/ if (mimeContent == null) { // no recipients, cancel return HttpStatus.SC_NO_CONTENT; } else { sendMessage(null, mimeContent); return HttpStatus.SC_OK; } }
From source file:davmail.exchange.dav.DavExchangeSession.java
@Override public int sendEvent(String icsBody) throws IOException { String itemName = UUID.randomUUID().toString() + ".EML"; byte[] mimeContent = (new Event(getFolderPath(DRAFTS), itemName, "urn:content-classes:calendarmessage", icsBody, null, null)).createMimeContent(); if (mimeContent == null) { // no recipients, cancel return HttpStatus.SC_NO_CONTENT; } else {/*from w w w . j a va 2 s . c om*/ sendMessage(mimeContent); return HttpStatus.SC_OK; } }