You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by ch...@apache.org on 2014/09/30 16:33:26 UTC
git commit: abbreviations are not allowed in Accept header
Repository: olingo-odata4
Updated Branches:
refs/heads/master 0eb95ed72 -> bd4ad859a
abbreviations are not allowed in Accept header
Change-Id: Ib0250e649af086359292deaa305defb3a660e5c5
Signed-off-by: Christian Amend <ch...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/bd4ad859
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/bd4ad859
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/bd4ad859
Branch: refs/heads/master
Commit: bd4ad859a699f3fc5536c26d95960cfdaa03f6a5
Parents: 0eb95ed
Author: Klaus Straubinger <kl...@sap.com>
Authored: Tue Sep 30 16:22:00 2014 +0200
Committer: Christian Amend <ch...@apache.org>
Committed: Tue Sep 30 16:33:13 2014 +0200
----------------------------------------------------------------------
.../org/apache/olingo/commons/api/format/AcceptType.java | 9 +++------
.../apache/olingo/commons/api/format/AcceptTypeTest.java | 7 +++++--
2 files changed, 8 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bd4ad859/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/AcceptType.java
----------------------------------------------------------------------
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 2ac9a27..9ab9056 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
@@ -103,10 +103,7 @@ public class AcceptType {
final String params = (typesAndParameters.length > 1 ? typesAndParameters[1] : null);
String[] tokens = types.split(TypeUtil.TYPE_SUBTYPE_SEPARATOR);
- if (tokens.length == 1) {
- typeSubtype.add(tokens[0]);
- typeSubtype.add(TypeUtil.MEDIA_TYPE_WILDCARD);
- } else if (tokens.length == 2) {
+ if (tokens.length == 2) {
if (tokens[0] == null || tokens[0].isEmpty()) {
throw new IllegalArgumentException("No type found in format '" + format + "'.");
} else if (tokens[1] == null || tokens[1].isEmpty()) {
@@ -116,8 +113,8 @@ public class AcceptType {
typeSubtype.add(tokens[1]);
}
} else {
- throw new IllegalArgumentException("Too many '" + TypeUtil.TYPE_SUBTYPE_SEPARATOR + "' in format '" + format
- + "'.");
+ throw new IllegalArgumentException("Not exactly one '" + TypeUtil.TYPE_SUBTYPE_SEPARATOR +
+ "' in format '" + format + "', or it is at the beginning or at the end.");
}
TypeUtil.parseParameters(params, parameters);
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bd4ad859/lib/commons-api/src/test/java/org/apache/olingo/commons/api/format/AcceptTypeTest.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/test/java/org/apache/olingo/commons/api/format/AcceptTypeTest.java b/lib/commons-api/src/test/java/org/apache/olingo/commons/api/format/AcceptTypeTest.java
index 9786ccd..242c814 100644
--- a/lib/commons-api/src/test/java/org/apache/olingo/commons/api/format/AcceptTypeTest.java
+++ b/lib/commons-api/src/test/java/org/apache/olingo/commons/api/format/AcceptTypeTest.java
@@ -38,8 +38,6 @@ public class AcceptTypeTest {
assertTrue(atl.get(0).matches(ContentType.create("a/a")));
assertTrue(atl.get(0).matches(ContentType.create("b/b")));
-
- assertEquals("*/*", AcceptType.create("*").get(0).toString());
}
@Test
@@ -113,6 +111,11 @@ public class AcceptTypeTest {
}
@Test(expected = IllegalArgumentException.class)
+ public void abbreviationsNotAllowed() {
+ AcceptType.create("application");
+ }
+
+ @Test(expected = IllegalArgumentException.class)
public void testWrongQParameter() {
AcceptType.create(" a/a;q=z ");
}