From 34825ab062743f95164a2742e457d4a3b7ded094 Mon Sep 17 00:00:00 2001 From: Christian Amend Date: Tue, 30 Sep 2014 17:22:36 +0200 Subject: [PATCH] [OLINGO-447] Also accept the * accept header --- .../fit/tecsvc/http/BasicHttpITCase.java | 20 +++++++++++++------ .../olingo/fit/tecsvc/http/PingITCase.java | 9 ++++++++- .../olingo/commons/api/format/AcceptType.java | 13 +++++++----- 3 files changed, 30 insertions(+), 12 deletions(-) diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/http/BasicHttpITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/http/BasicHttpITCase.java index 637bbc04b..f8c4c2f3f 100644 --- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/http/BasicHttpITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/http/BasicHttpITCase.java @@ -18,17 +18,19 @@ */ package org.apache.olingo.fit.tecsvc.http; -import org.apache.olingo.commons.api.format.ContentType; -import org.apache.olingo.commons.api.http.HttpHeader; -import org.apache.olingo.fit.tecsvc.TecSvcConst; -import org.junit.Test; +import static org.junit.Assert.assertEquals; import java.net.HttpURLConnection; import java.net.URL; -import static org.junit.Assert.assertEquals; +import org.apache.olingo.client.api.CommonODataClient; +import org.apache.olingo.commons.api.format.ContentType; +import org.apache.olingo.commons.api.http.HttpHeader; +import org.apache.olingo.fit.AbstractBaseTestITCase; +import org.apache.olingo.fit.tecsvc.TecSvcConst; +import org.junit.Test; -public class BasicHttpITCase { +public class BasicHttpITCase extends AbstractBaseTestITCase{ private static final String SERVICE_URI = TecSvcConst.BASE_URI + "/"; @@ -114,6 +116,12 @@ public class BasicHttpITCase { assertEquals("4.0", v); } + @Override + protected CommonODataClient getClient() { + // TODO Auto-generated method stub + return null; + } + } diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/http/PingITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/http/PingITCase.java index 78db59d94..f706ddd8f 100644 --- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/http/PingITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/http/PingITCase.java @@ -18,6 +18,8 @@ */ package org.apache.olingo.fit.tecsvc.http; +import org.apache.olingo.client.api.CommonODataClient; +import org.apache.olingo.fit.AbstractBaseTestITCase; import org.apache.olingo.fit.tecsvc.TecSvcConst; import org.junit.Test; import org.slf4j.Logger; @@ -28,7 +30,7 @@ import java.net.URL; import static org.junit.Assert.assertEquals; -public class PingITCase { +public class PingITCase extends AbstractBaseTestITCase{ private static final Logger LOG = LoggerFactory.getLogger(PingITCase.class); @@ -64,4 +66,9 @@ public class PingITCase { assertEquals(200, code); } + @Override + protected CommonODataClient getClient() { + return null; + } + } diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/AcceptType.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/AcceptType.java index 9ab905684..21832423b 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/AcceptType.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/AcceptType.java @@ -27,7 +27,7 @@ import java.util.TreeMap; /** * Internally used {@link AcceptType} for OData library. - * + * * See RFC 7231, chapter 5.3.2: *
  * Accept = #( media-range [ accept-params ] )
@@ -74,11 +74,11 @@ public class AcceptType {
     }
     List typeSubtype = new ArrayList();
     parameters = createParameterMap();
-    
+
     parse(type, typeSubtype, parameters);
     this.type = typeSubtype.get(0);
     subtype = typeSubtype.get(1);
-    
+
     if (TypeUtil.MEDIA_TYPE_WILDCARD.equals(this.type) && !TypeUtil.MEDIA_TYPE_WILDCARD.equals(subtype)) {
       throw new IllegalArgumentException("Illegal combination of WILDCARD type with NONE WILDCARD subtype.");
     }
@@ -97,7 +97,7 @@ public class AcceptType {
 
   private static void parse(final String format, final List typeSubtype,
       final Map parameters) {
-    
+
     final String[] typesAndParameters = format.split(TypeUtil.PARAMETER_SEPARATOR, 2);
     final String types = typesAndParameters[0];
     final String params = (typesAndParameters.length > 1 ? typesAndParameters[1] : null);
@@ -112,6 +112,9 @@ public class AcceptType {
         typeSubtype.add(tokens[0]);
         typeSubtype.add(tokens[1]);
       }
+    } else if (tokens.length == 1 && "*".equals(tokens[0])) {
+      typeSubtype.add(tokens[0]);
+      typeSubtype.add(tokens[0]);
     } else {
       throw new IllegalArgumentException("Not exactly one '" + TypeUtil.TYPE_SUBTYPE_SEPARATOR +
           "' in format '" + format + "', or it is at the beginning or at the end.");
@@ -135,7 +138,7 @@ public class AcceptType {
     }
 
     sort(result);
-    
+
     return result;
   }