diff options
author | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2011-01-08 20:18:56 +0000 |
---|---|---|
committer | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2011-01-08 20:18:56 +0000 |
commit | 65b330f412b857057edd2029ff08ab53a037ce65 (patch) | |
tree | 6703fa99a1a659a6c5ee7a81a37952632873be53 /sca-java-2.x/trunk/modules/binding-atom-runtime/src | |
parent | 1e84a3a12aefb9d5e8c116556779cd9d7d02dc89 (diff) |
TUSCANY-3814 - Fixing http headers to avoid hanging IE6 when consuming tuscany atom feeds
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1056789 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/binding-atom-runtime/src')
6 files changed, 95 insertions, 100 deletions
diff --git a/sca-java-2.x/trunk/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingInvoker.java b/sca-java-2.x/trunk/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingInvoker.java index e569276b08..4af8c3ca14 100644 --- a/sca-java-2.x/trunk/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingInvoker.java +++ b/sca-java-2.x/trunk/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingInvoker.java @@ -206,7 +206,7 @@ class AtomBindingInvoker implements Invoker { StringWriter writer = new StringWriter(); feedEntry.writeTo(writer); // postMethod.setHeader("Content-type", "application/atom+xml; charset=utf-8"); - TUSCANY-3734 - postMethod.setHeader("Content-type", "application/atom+xml;type=entry"); + postMethod.setHeader("Content-type", "application/atom+xml"); postMethod.setEntity(new StringEntity(writer.toString())); response = httpClient.execute(postMethod); @@ -305,7 +305,7 @@ class AtomBindingInvoker implements Invoker { StringWriter writer = new StringWriter(); feedEntry.writeTo(writer); //putMethod.setHeader("Content-type", "application/atom+xml; charset=utf-8"); - TUSCANY-3734 - putMethod.setHeader("Content-type", "application/atom+xml;type=entry"); + putMethod.setHeader("Content-type", "application/atom+xml"); putMethod.setEntity(new StringEntity(writer.toString())); response = httpClient.execute(putMethod); diff --git a/sca-java-2.x/trunk/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingListenerServlet.java b/sca-java-2.x/trunk/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingListenerServlet.java index e8f1edc44a..b5b8763f3c 100644 --- a/sca-java-2.x/trunk/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingListenerServlet.java +++ b/sca-java-2.x/trunk/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingListenerServlet.java @@ -169,9 +169,6 @@ class AtomBindingListenerServlet extends HttpServlet { // System.out.println( "AtomBindingListener.doGet cache context=" + cacheContext ); // Get the request path - //int servletPathLength = request.getContextPath().length() + request.getServletPath().length(); - //String path = URLDecoder.decode(request.getRequestURI().substring(servletPathLength), "UTF-8"); - String path = URLDecoder.decode(HTTPUtils.getRequestPath(request), "UTF-8"); logger.fine("get " + request.getRequestURI()); @@ -185,7 +182,7 @@ class AtomBindingListenerServlet extends HttpServlet { <atom:title type="text">resource</atom:title> <collection href="http://luck.ibm.com:8084/customer"> <atom:title type="text">entries</atom:title> - <accept>application/atom+xml;type=entry</accept> + <accept>application/atom+xml</accept> <categories /> </collection> </workspace> @@ -225,10 +222,8 @@ class AtomBindingListenerServlet extends HttpServlet { } else { collection.setTitle("entries"); } - collection.addAccepts("application/atom+xml;type=feed"); - collection.addAccepts("application/json;type=feed"); - collection.addAccepts("application/atom+xml;type=entry"); - collection.addAccepts("application/json;type=entry"); + collection.addAccepts("application/atom+xml"); + collection.addAccepts("application/json"); List<Category> categories = feed.getCategories(); if ( categories != null ) { collection.addCategories(categories, false, null); @@ -239,8 +234,8 @@ class AtomBindingListenerServlet extends HttpServlet { } else { collection.setTitle("entries"); - collection.addAccepts("application/atom+xml;type=entry"); - collection.addAccepts("application/json;type=entry"); + collection.addAccepts("application/atom+xml"); + collection.addAccepts("application/json"); collection.addCategories().setFixed(false); } workspace.addCollection(collection); @@ -319,7 +314,7 @@ class AtomBindingListenerServlet extends HttpServlet { String preferredType = getContentPreference( acceptType ); if (( preferredType != null ) && ((preferredType.indexOf( "json") > -1) || (preferredType.indexOf( "JSON") > -1 ))) { // JSON response body - response.setContentType("application/json;type=feed"); + response.setContentType("application/json"); try { Abdera abdera = new Abdera(); @@ -332,7 +327,7 @@ class AtomBindingListenerServlet extends HttpServlet { } else { // Write the Atom feed - response.setContentType("application/atom+xml;type=feed"); + response.setContentType("application/atom+xml"); try { feed.getDocument().writeTo(response.getOutputStream()); } catch (IOException ioe) { @@ -449,7 +444,7 @@ class AtomBindingListenerServlet extends HttpServlet { String preferredType = getContentPreference( acceptType ); if (( preferredType != null ) && ((preferredType.indexOf( "json") > -1) || (preferredType.indexOf( "JSON") > -1 ))) { // JSON response body - response.setContentType("application/json;type=entry"); + response.setContentType("application/json"); try { Abdera abdera = new Abdera(); WriterFactory wf = abdera.getWriterFactory(); @@ -460,7 +455,7 @@ class AtomBindingListenerServlet extends HttpServlet { } } else { // XML response body - response.setContentType("application/atom+xml;type=entry"); + response.setContentType("application/atom+xml"); try { feedEntry.writeTo(getWriter(response)); } catch (IOException ioe) { @@ -657,7 +652,7 @@ class AtomBindingListenerServlet extends HttpServlet { // Write the created Atom entry response.setStatus(HttpServletResponse.SC_CREATED); - response.setContentType("application/atom+xml;type=entry"); + response.setContentType("application/atom+xml"); try { createdFeedEntry.writeTo(getWriter(response)); } catch (ParseException pe) { diff --git a/sca-java-2.x/trunk/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/utils/AtomBindingHttpUtils.java b/sca-java-2.x/trunk/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/utils/AtomBindingHttpUtils.java index 684dc044d1..f6f914c71c 100644 --- a/sca-java-2.x/trunk/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/utils/AtomBindingHttpUtils.java +++ b/sca-java-2.x/trunk/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/utils/AtomBindingHttpUtils.java @@ -42,8 +42,8 @@ public class AtomBindingHttpUtils { //set Cache-Control to no-cache to avoid intermediary //proxy/reverse-proxy caches and always hit the server //that would identify if the value was current or not - response.setHeader("Cache-Control", "no-cache"); - response.setHeader("Expires", new Date(0).toGMTString()); + //response.setHeader("Cache-Control", "no-cache"); + //response.setHeader("Expires", new Date(0).toGMTString()); } diff --git a/sca-java-2.x/trunk/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/ContentNegotiationTest.java b/sca-java-2.x/trunk/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/ContentNegotiationTest.java index 0b999ae1c9..e9ebf046a6 100644 --- a/sca-java-2.x/trunk/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/ContentNegotiationTest.java +++ b/sca-java-2.x/trunk/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/ContentNegotiationTest.java @@ -6,15 +6,15 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations - * under the License. + * under the License. */ package org.apache.tuscany.sca.binding.atom; @@ -49,7 +49,7 @@ import org.junit.Test; * Tests use of content negotiation for Atom binding in Tuscany. * Uses the SCA provided Provider composite to act as a server. * Uses the Abdera provided Client to act as a client. - * + * * @version $Rev$ $Date$ */ public class ContentNegotiationTest { @@ -60,7 +60,7 @@ public class ContentNegotiationTest { protected static CustomerClient testService; protected static Abdera abdera; protected static AbderaClient client; - protected static Parser abderaParser; + protected static Parser abderaParser; protected static String lastId; @BeforeClass @@ -111,7 +111,7 @@ public class ContentNegotiationTest { entry.setContentElement(content); RequestOptions opts = new RequestOptions(); - final String contentType = "application/atom+xml; type=entry"; + final String contentType = "application/atom+xml"; opts.setContentType(contentType); // AtomTestCaseUtils.printRequestHeaders( "Post request headers", " ", opts ); IRI colUri = new IRI(providerURI).resolve("customer"); @@ -144,7 +144,7 @@ public class ContentNegotiationTest { Assert.assertEquals(200, res.getStatus()); String returnedContentType = res.getContentType().toString().trim(); // Assert.assertEquals(contentType, returnedContentType ); - res.release(); + res.release(); } @Test @@ -157,7 +157,7 @@ public class ContentNegotiationTest { ClientResponse res = client.get(colUri.toString() + "/" + lastId, opts); try { Assert.assertEquals(200, res.getStatus()); - // Abdera 0.4 throws exception on getContentType with application/json. + // Abdera 0.4 throws exception on getContentType with application/json. // System.out.println( "ContentNegotiationTest.testJSONEntryGet contentType=" + res.getContentType()); String contentType = res.getHeader( "Content-Type"); Assert.assertTrue( -1 < contentType.indexOf( "application/json" )); @@ -173,12 +173,12 @@ public class ContentNegotiationTest { // AtomTestCaseUtils.printResponseHeaders( "JSON Entry response headers:", " ", res ); // System.out.println( "ContentNegotiationTest.testJSONEntryGet JSON entry body=" + responseBody ); } finally { - res.release(); + res.release(); } } @Test - public void testXMLFeedGet() throws Exception { + public void testXMLFeedGet() throws Exception { //System.out.println(">>>ContentNegotiationTest.testXMLFeedGet"); RequestOptions opts = new RequestOptions(); opts.setHeader( "Accept", "application/atom+xml" ); @@ -207,10 +207,10 @@ public class ContentNegotiationTest { } finally { res.release(); } - } + } @Test - public void testJSONFeedGet() throws Exception { + public void testJSONFeedGet() throws Exception { //System.out.println(">>>ContentNegotiationTest.testJSONFeedGet"); RequestOptions opts = new RequestOptions(); opts.setHeader( "Accept", "application/json" ); @@ -221,7 +221,7 @@ public class ContentNegotiationTest { try { // Assert feed provided since no predicates Assert.assertEquals(200, res.getStatus()); - // Abdera 0.4 throws exception on getContentType with application/json. + // Abdera 0.4 throws exception on getContentType with application/json. // System.out.println( "ContentNegotiationTest.testJSONEntryGet contentType=" + res.getContentType()); String contentType = res.getHeader( "Content-Type"); Assert.assertTrue( -1 < contentType.indexOf( "application/json" )); @@ -243,7 +243,7 @@ public class ContentNegotiationTest { } protected String readResponse( Reader responseReader ) { - if ( responseReader == null ) return ""; + if ( responseReader == null ) return ""; StringBuffer sb = new StringBuffer(1024); try { int charValue = 0; diff --git a/sca-java-2.x/trunk/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderEntryEntityTagsTestCase.java b/sca-java-2.x/trunk/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderEntryEntityTagsTestCase.java index 6dbb15f6b9..c39bee65f6 100644 --- a/sca-java-2.x/trunk/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderEntryEntityTagsTestCase.java +++ b/sca-java-2.x/trunk/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderEntryEntityTagsTestCase.java @@ -6,15 +6,15 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations - * under the License. + * under the License. */ package org.apache.tuscany.sca.binding.atom; @@ -44,10 +44,10 @@ import org.junit.Test; /** * Tests use of server provided entry entity tags for Atom binding in Tuscany. * Tests conditional gets (e.g. get if-none-match) or conditional posts (post if-match) - * using entity tags or last modified header entries. + * using entity tags or last modified header entries. * Uses the SCA provided Provider composite to act as a server. * Uses the Abdera provided Client to act as a client. - * + * * @version $Rev$ $Date$ */ public class ProviderEntryEntityTagsTestCase { @@ -58,7 +58,7 @@ public class ProviderEntryEntityTagsTestCase { protected static CustomerClient testService; protected static Abdera abdera; protected static AbderaClient client; - protected static Parser abderaParser; + protected static Parser abderaParser; protected static String eTag; protected static Date lastModified; protected static final SimpleDateFormat dateFormat = new SimpleDateFormat( "EEE, dd MMM yyyy HH:mm:ss Z" ); // RFC 822 date time @@ -94,10 +94,10 @@ public class ProviderEntryEntityTagsTestCase { public void testEmptyCachePost() throws Exception { // Pseudo-code // 1) Example HTTP POST request (new entry put, new etag response) - // User client post request + // User client post request // POST /myblog/entries HTTP/1.1 // Slug: First Post - // + // // <?xml version="1.0" ?> // <entry xmlns="http://www.w3.org/2005/Atom"> // <title>Atom-Powered Robots Run Amok</title> @@ -116,7 +116,7 @@ public class ProviderEntryEntityTagsTestCase { // Content-Location: http://example.org/edit/first-post.atom // ETag: "e180ee84f0671b1" // Last-Modified: Fri, 25 Jul 2008 14:36:44 -0500 - // + // // <?xml version="1.0" ?> // <entry xmlns="http://www.w3.org/2005/Atom"> // <title>Atom-Powered Robots Run Amok</title> @@ -124,7 +124,7 @@ public class ProviderEntryEntityTagsTestCase { // <updated>2007-02-123T17:09:02Z</updated> // <author><name>Captain Lansing</name></author> // <content>It's something moving... solid metal</content> - // </entry> + // </entry> // Testing of entry creation Factory factory = abdera.getFactory(); @@ -143,7 +143,7 @@ public class ProviderEntryEntityTagsTestCase { entry.setContentElement(content); RequestOptions opts = new RequestOptions(); - final String contentType = "application/atom+xml; type=entry"; + final String contentType = "application/atom+xml"; opts.setContentType(contentType); // AtomTestCaseUtils.printRequestHeaders( "Post request headers", " ", opts ); IRI colUri = new IRI(providerURI).resolve("customer"); @@ -155,7 +155,7 @@ public class ProviderEntryEntityTagsTestCase { // Assert response header Location: http://example.org/edit/first-post.atom // Assert response header Content-Location: http://example.org/edit/first-post.atom // Assert response header ETag: "e180ee84f0671b1" - // Assert response header Last-Modified: Fri, 25 Jul 2008 14:36:44 -0500 + // Assert response header Last-Modified: Fri, 25 Jul 2008 14:36:44 -0500 // Assert collection size is 1. Assert.assertEquals(201, res.getStatus()); Assert.assertEquals(contentType, res.getContentType().toString().trim()); @@ -163,7 +163,7 @@ public class ProviderEntryEntityTagsTestCase { // Assert.assertEquals( "", res.getContentLocation().toString() ); // Save eTag for subsequent tests; eTag = res.getHeader( "ETag" ); - Assert.assertNotNull( eTag ); + Assert.assertNotNull( eTag ); lastModified = res.getLastModified(); Assert.assertNotNull(lastModified); } @@ -174,7 +174,7 @@ public class ProviderEntryEntityTagsTestCase { // User client PUT request // PUT /edit/first-post.atom HTTP/1.1 // > If-Match: "e180ee84f0671b1" - // + // // <?xml version="1.0" ?> // <entry xmlns="http://www.w3.org/2005/Atom"> // <title>Atom-Powered Robots Run Amok</title> @@ -200,7 +200,7 @@ public class ProviderEntryEntityTagsTestCase { entry.setContentElement(content); RequestOptions opts = new RequestOptions(); - final String contentType = "application/atom+xml; type=entry"; + final String contentType = "application/atom+xml"; opts.setContentType(contentType); opts.setHeader( "If-None-Match", eTag); @@ -230,7 +230,7 @@ public class ProviderEntryEntityTagsTestCase { // > If-None-Match: "e180ee84f0671b1" RequestOptions opts = new RequestOptions(); - final String contentType = "application/atom+xml; type=entry"; + final String contentType = "application/atom+xml"; opts.setContentType(contentType); opts.setHeader( "If-None-Match", "123456"); opts.setHeader( "Pragma", "no-cache"); // turn off client caching @@ -261,7 +261,7 @@ public class ProviderEntryEntityTagsTestCase { Assert.assertEquals(contentType, res.getContentType().toString().trim()); // Assert.assertNotNull( res.getLocation().toString() ); // Assert.assertEquals( "", res.getContentLocation().toString() ); - Assert.assertNotNull( res.getHeader( "ETag" ) ); + Assert.assertNotNull( res.getHeader( "ETag" ) ); lastModified = res.getLastModified(); Assert.assertNotNull(lastModified); res.release(); @@ -275,10 +275,10 @@ public class ProviderEntryEntityTagsTestCase { // > If-None-Match: "e180ee84f0671b1" RequestOptions opts = new RequestOptions(); - final String contentType = "application/atom+xml; type=entry"; + final String contentType = "application/atom+xml"; opts.setContentType(contentType); opts.setHeader( "If-None-Match", eTag); - opts.setHeader( "Pragma", "no-cache"); // turn off client caching + opts.setHeader( "Pragma", "no-cache"); // turn off client caching IRI colUri = new IRI(providerURI).resolve("customer"); // res = client.post(colUri.toString() + "?test=foo", entry, opts); @@ -294,7 +294,7 @@ public class ProviderEntryEntityTagsTestCase { // Assert header ETag: "e180ee84f0671b1" // Assert header Last-Modified: Fri, 25 Jul 2008 14:36:44 -0500 // Assert.assertEquals(304, res.getStatus()); - res.release(); + res.release(); } @@ -305,7 +305,7 @@ public class ProviderEntryEntityTagsTestCase { // GET /edit/first-post.atom HTTP/1.1 // > If-Modified-Since: Sat, 29 Oct 2025 19:43:31 GMT RequestOptions opts = new RequestOptions(); - final String contentType = "application/atom+xml; type=entry"; + final String contentType = "application/atom+xml"; opts.setContentType(contentType); opts.setHeader( "If-Modified-Since", "Sat, 29 Oct 2025 19:43:31 GMT"); // "EEE, dd MMM yyyy HH:mm:ss Z // RFC 822 Date opts.setHeader( "Pragma", "no-cache"); // turn off client caching @@ -325,7 +325,7 @@ public class ProviderEntryEntityTagsTestCase { // Assert response status code is 304 Not Modified. Assert.assertEquals(304, res.getStatus()); - res.release(); + res.release(); } @Test @@ -335,7 +335,7 @@ public class ProviderEntryEntityTagsTestCase { // GET /edit/first-post.atom HTTP/1.1 // > If-Modified-Since: Sat, 29 Oct 1844 19:43:31 GMT RequestOptions opts = new RequestOptions(); - final String contentType = "application/atom+xml; type=entry"; + final String contentType = "application/atom+xml"; opts.setContentType(contentType); opts.setHeader( "If-Modified-Since", "Sat, 29 Oct 1844 19:43:31 GMT"); // "EEE, dd MMM yyyy HH:mm:ss Z // RFC 822 Date opts.setHeader( "Pragma", "no-cache"); // turn off client caching @@ -355,12 +355,12 @@ public class ProviderEntryEntityTagsTestCase { // Assert response status code is 200 OK. // Assert header ETag: "e180ee84f0671b1" - // Assert header Last-Modified: Greater than If-Mod + // Assert header Last-Modified: Greater than If-Mod Assert.assertEquals(200, res.getStatus()); Assert.assertEquals(contentType, res.getContentType().toString().trim()); // Assert.assertNotNull( res.getLocation().toString() ); // Assert.assertEquals( "", res.getContentLocation().toString() ); - Assert.assertNotNull( res.getHeader( "ETag" ) ); + Assert.assertNotNull( res.getHeader( "ETag" ) ); lastModified = res.getLastModified(); Assert.assertNotNull(lastModified); res.release(); @@ -373,7 +373,7 @@ public class ProviderEntryEntityTagsTestCase { // GET /edit/first-post.atom HTTP/1.1 // > If-Unmodified-Since: Sat, 29 Oct 2025 19:43:31 GMT RequestOptions opts = new RequestOptions(); - final String contentType = "application/atom+xml; type=entry"; + final String contentType = "application/atom+xml"; opts.setContentType(contentType); opts.setHeader( "If-Unmodified-Since", "Sat, 29 Oct 2050 19:43:31 GMT" ); opts.setHeader( "Pragma", "no-cache"); // turn off client caching @@ -396,9 +396,9 @@ public class ProviderEntryEntityTagsTestCase { // Assert header Location: http://example.org/edit/first-post.atom // Assert header Content-Location: http://example.org/edit/first-post.atom // Assert header ETag: "e180ee84f0671b1" - // Assert header Last-Modified: Less than If-Unmod + // Assert header Last-Modified: Less than If-Unmod Assert.assertEquals(200, res.getStatus()); - res.release(); + res.release(); } @Test @@ -409,7 +409,7 @@ public class ProviderEntryEntityTagsTestCase { // Host: example.org // > If-Unmodified-Since: Sat, 29 Oct 1844 19:43:31 GMT RequestOptions opts = new RequestOptions(); - final String contentType = "application/atom+xml; type=entry"; + final String contentType = "application/atom+xml"; opts.setContentType(contentType); opts.setHeader( "If-Unmodified-Since", "Sat, 29 Oct 1844 19:43:31 GMT" ); opts.setHeader( "Pragma", "no-cache"); // turn off client caching @@ -427,6 +427,6 @@ public class ProviderEntryEntityTagsTestCase { // Assert response status code is 304 Not Modified. Assert.assertEquals(304, res.getStatus()); - res.release(); + res.release(); } } diff --git a/sca-java-2.x/trunk/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderFeedEntityTagsTestCase.java b/sca-java-2.x/trunk/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderFeedEntityTagsTestCase.java index ddec9d4034..ad5a179562 100644 --- a/sca-java-2.x/trunk/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderFeedEntityTagsTestCase.java +++ b/sca-java-2.x/trunk/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderFeedEntityTagsTestCase.java @@ -6,15 +6,15 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations - * under the License. + * under the License. */ package org.apache.tuscany.sca.binding.atom; @@ -50,10 +50,10 @@ import org.junit.Test; /** * Tests use of server provided feed entity tags for Atom binding in Tuscany. * Tests conditional gets (e.g. get if-none-match) or conditional posts (post if-match) - * using entity tags and last modified entries in headers. + * using entity tags and last modified entries in headers. * Uses the SCA provided Provider composite to act as a server. * Uses the Abdera provided Client to act as a client. - * + * * @version $Rev$ $Date$ */ public class ProviderFeedEntityTagsTestCase { @@ -64,7 +64,7 @@ public class ProviderFeedEntityTagsTestCase { protected static CustomerClient testService; protected static Abdera abdera; protected static AbderaClient client; - protected static Parser abderaParser; + protected static Parser abderaParser; protected static String eTag; protected static Date lastModified; protected static final SimpleDateFormat dateFormat = new SimpleDateFormat( "EEE, dd MMM yyyy HH:mm:ss Z" ); // RFC 822 date time @@ -97,7 +97,7 @@ public class ProviderFeedEntityTagsTestCase { } @Test - public void testFeedBasics() throws Exception { + public void testFeedBasics() throws Exception { // System.out.println(">>>ProviderFeedEntityTagsTestCase.testFeedBasics"); // Normal feed request ClientResponse res = client.get(providerURI); @@ -126,14 +126,14 @@ public class ProviderFeedEntityTagsTestCase { } finally { res.release(); } - } + } @Test - public void testUnmodifiedGetIfMatch() throws Exception { + public void testUnmodifiedGetIfMatch() throws Exception { //System.out.println(">>>ProviderFeedEntityTagsTestCase.testFeedUnmodifiedGetIfMatch"); // Feed request with predicates RequestOptions opts = new RequestOptions(); - final String contentType = "application/atom+xml"; + final String contentType = "application/atom+xml"; opts.setContentType(contentType); opts.setHeader( "If-Match", eTag); @@ -154,14 +154,14 @@ public class ProviderFeedEntityTagsTestCase { } finally { res.release(); } - } + } @Test - public void testUnmodifiedGetIfNoneMatch() throws Exception { + public void testUnmodifiedGetIfNoneMatch() throws Exception { //System.out.println(">>>ProviderFeedEntityTagsTestCase.testFeedUnmodifiedGetIfNoneMatch"); // Feed request with predicates RequestOptions opts = new RequestOptions(); - final String contentType = "application/atom+xml"; + final String contentType = "application/atom+xml"; opts.setContentType(contentType); opts.setHeader( "If-None-Match", eTag); @@ -173,14 +173,14 @@ public class ProviderFeedEntityTagsTestCase { } finally { res.release(); } - } + } @Test - public void testUnmodifiedGetIfUnModified() throws Exception { + public void testUnmodifiedGetIfUnModified() throws Exception { //System.out.println(">>>ProviderFeedEntityTagsTestCase.testFeedUnmodifiedGetIfUnModified"); // Feed request with predicates RequestOptions opts = new RequestOptions(); - final String contentType = "application/atom+xml"; + final String contentType = "application/atom+xml"; opts.setContentType(contentType); opts.setHeader( "If-Unmodified-Since", dateFormat.format( new Date() )); @@ -193,14 +193,14 @@ public class ProviderFeedEntityTagsTestCase { } finally { res.release(); } - } + } @Test - public void testUnmodifiedGetIfModified() throws Exception { + public void testUnmodifiedGetIfModified() throws Exception { //System.out.println(">>>ProviderFeedEntityTagsTestCase.testFeedUnmodifiedGetIfModified"); // Feed request with predicates RequestOptions opts = new RequestOptions(); - final String contentType = "application/atom+xml"; + final String contentType = "application/atom+xml"; opts.setContentType(contentType); opts.setHeader( "If-Modified-Since", dateFormat.format( new Date( 0 ) )); @@ -214,14 +214,14 @@ public class ProviderFeedEntityTagsTestCase { String thisETag = res.getHeader("ETag"); Assert.assertNotNull( thisETag ); Date thisLastModified = res.getLastModified(); - Assert.assertNotNull( thisLastModified ); + Assert.assertNotNull( thisLastModified ); } finally { res.release(); } - } + } @Test - public void testModifiedGetIfNoneMatch() throws Exception { + public void testModifiedGetIfNoneMatch() throws Exception { //System.out.println(">>>ProviderFeedEntityTagsTestCase.testFeedModifiedGetIfNoneMatch"); // Post some new content to the feed. Factory factory = abdera.getFactory(); @@ -236,14 +236,14 @@ public class ProviderFeedEntityTagsTestCase { entry.setContentElement(content); RequestOptions opts = new RequestOptions(); - String contentType = "application/atom+xml; type=entry"; + String contentType = "application/atom+xml"; opts.setContentType(contentType); IRI colUri = new IRI(providerURI).resolve("customer"); ClientResponse res = client.post(colUri.toString(), entry, opts); // Feed request with predicates opts = new RequestOptions(); - contentType = "application/atom+xml"; + contentType = "application/atom+xml"; opts.setContentType(contentType); opts.setHeader( "If-None-Match", eTag); @@ -258,14 +258,14 @@ public class ProviderFeedEntityTagsTestCase { } finally { res.release(); } - } + } @Test - public void testModifiedGetIfMatch() throws Exception { + public void testModifiedGetIfMatch() throws Exception { //System.out.println(">>>ProviderFeedEntityTagsTestCase.testFeedModifiedGetIfMatch"); // Feed request with predicates RequestOptions opts = new RequestOptions(); - final String contentType = "application/atom+xml"; + final String contentType = "application/atom+xml"; opts.setContentType(contentType); opts.setHeader( "If-Match", eTag); @@ -287,36 +287,36 @@ public class ProviderFeedEntityTagsTestCase { } finally { res.release(); } - } + } @Test - public void testModifiedGetIfUnModified() throws Exception { + public void testModifiedGetIfUnModified() throws Exception { //System.out.println(">>>ProviderFeedEntityTagsTestCase.testFeedModifiedGetIfUnModified"); // Feed request with predicates RequestOptions opts = new RequestOptions(); - final String contentType = "application/atom+xml"; + final String contentType = "application/atom+xml"; opts.setContentType(contentType); opts.setHeader( "If-Unmodified-Since", dateFormat.format( previousSecond(lastModified) )); ClientResponse res = client.get(providerURI, opts); Assert.assertNotNull(res); try { - // Should return 412 - Feed not provided since feed is modified since. + // Should return 412 - Feed not provided since feed is modified since. Assert.assertEquals(412, res.getStatus()); } finally { res.release(); } - } + } @Test - public void testModifiedGetIfModified() throws Exception { + public void testModifiedGetIfModified() throws Exception { //System.out.println(">>>ProviderFeedEntityTagsTestCase.testFeedModifiedGetIfModified"); // Feed request with predicates RequestOptions opts = new RequestOptions(); - final String contentType = "application/atom+xml"; + final String contentType = "application/atom+xml"; opts.setContentType(contentType); opts.setHeader( "If-Modified-Since", dateFormat.format( new Date() )); - + ClientResponse res = client.get(providerURI, opts); Assert.assertNotNull(res); try { @@ -341,11 +341,11 @@ public class ProviderFeedEntityTagsTestCase { String thisETag = res.getHeader("ETag"); Assert.assertNotNull( thisETag ); Date thisLastModified = res.getLastModified(); - Assert.assertNotNull( thisLastModified ); + Assert.assertNotNull( thisLastModified ); } finally { res.release(); } - } + } public static void printFeed( String title, String indent, Feed feed ) { |