[OLINGO-447] Also accept the * accept header
This commit is contained in:
parent
bd4ad859a6
commit
34825ab062
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ import java.util.TreeMap;
|
|||
|
||||
/**
|
||||
* Internally used {@link AcceptType} for OData library.
|
||||
*
|
||||
*
|
||||
* See RFC 7231, chapter 5.3.2:
|
||||
* <pre>
|
||||
* Accept = #( media-range [ accept-params ] )
|
||||
|
@ -74,11 +74,11 @@ public class AcceptType {
|
|||
}
|
||||
List<String> typeSubtype = new ArrayList<String>();
|
||||
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<String> typeSubtype,
|
||||
final Map<String, String> 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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue