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 2013/09/20 15:34:01 UTC
[39/59] [abbrv] cleanup of odata fit tests
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/b18130ac/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/MiscChangeTest.java
----------------------------------------------------------------------
diff --git a/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/MiscChangeTest.java b/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/MiscChangeTest.java
index 1576337..ca0db8e 100644
--- a/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/MiscChangeTest.java
+++ b/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/MiscChangeTest.java
@@ -1,37 +1,36 @@
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * 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
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * 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
+ * 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.
+ * 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.
******************************************************************************/
package org.apache.olingo.odata2.fit.ref;
import static org.junit.Assert.assertEquals;
import org.apache.http.HttpResponse;
-import org.junit.Test;
-
import org.apache.olingo.odata2.api.commons.HttpContentType;
import org.apache.olingo.odata2.api.commons.HttpHeaders;
import org.apache.olingo.odata2.api.commons.HttpStatusCodes;
import org.apache.olingo.odata2.api.commons.ODataHttpMethod;
+import org.junit.Test;
/**
* Tests employing the reference scenario that use neither XML nor JSON
* and that change data in some way
- *
+ *
*/
public class MiscChangeTest extends AbstractRefTest {
@@ -40,7 +39,8 @@ public class MiscChangeTest extends AbstractRefTest {
deleteUriOk("Employees('2')");
deleteUriOk("Managers('3')");
deleteUriOk("Teams('2')");
- callUri(ODataHttpMethod.DELETE, "Rooms('1')", HttpHeaders.IF_MATCH, "W/\"1\"", null, null, HttpStatusCodes.NO_CONTENT);
+ callUri(ODataHttpMethod.DELETE, "Rooms('1')", HttpHeaders.IF_MATCH, "W/\"1\"", null, null,
+ HttpStatusCodes.NO_CONTENT);
callUri(ODataHttpMethod.DELETE, "Container2.Photos(Id=1,Type='image%2Fpng')",
HttpHeaders.IF_MATCH, "W/\"1\"", null, null, HttpStatusCodes.NO_CONTENT);
@@ -87,7 +87,9 @@ public class MiscChangeTest extends AbstractRefTest {
checkMediaType(response, HttpContentType.APPLICATION_OCTET_STREAM);
assertEquals("00", getBody(response));
- response = callUri(ODataHttpMethod.PUT, "Container2.Photos(Id=2,Type='image%2Fbmp')/$value", null, null, "00", IMAGE_GIF, HttpStatusCodes.NO_CONTENT);
+ response =
+ callUri(ODataHttpMethod.PUT, "Container2.Photos(Id=2,Type='image%2Fbmp')/$value", null, null, "00", IMAGE_GIF,
+ HttpStatusCodes.NO_CONTENT);
checkEtag(response, "W/\"2\"");
}
@@ -96,11 +98,13 @@ public class MiscChangeTest extends AbstractRefTest {
putUri("Employees('2')/Age/$value", "42", HttpContentType.TEXT_PLAIN, HttpStatusCodes.NO_CONTENT);
String url = "Container2.Photos(Id=3,Type='image%2Fjpeg')/Image/$value";
- callUri(ODataHttpMethod.PUT, url, HttpHeaders.ETAG, "W/\"3\"", "4711", HttpContentType.APPLICATION_OCTET_STREAM, HttpStatusCodes.NO_CONTENT);
+ callUri(ODataHttpMethod.PUT, url, HttpHeaders.ETAG, "W/\"3\"", "4711", HttpContentType.APPLICATION_OCTET_STREAM,
+ HttpStatusCodes.NO_CONTENT);
assertEquals("4711", getBody(callUri(url)));
url = "Container2.Photos(Id=4,Type='foo')/BinaryData/$value";
- HttpResponse response = callUri(ODataHttpMethod.PUT, url, HttpHeaders.ETAG, "W/\"4\"", "4711", IMAGE_JPEG, HttpStatusCodes.NO_CONTENT);
+ HttpResponse response =
+ callUri(ODataHttpMethod.PUT, url, HttpHeaders.ETAG, "W/\"4\"", "4711", IMAGE_JPEG, HttpStatusCodes.NO_CONTENT);
checkEtag(response, "W/\"4\"");
assertEquals("4711", getBody(callUri(url)));
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/b18130ac/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/MiscReadOnlyTest.java
----------------------------------------------------------------------
diff --git a/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/MiscReadOnlyTest.java b/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/MiscReadOnlyTest.java
index e99f13e..b34f747 100644
--- a/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/MiscReadOnlyTest.java
+++ b/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/MiscReadOnlyTest.java
@@ -1,20 +1,20 @@
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * 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
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * 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
+ * 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.
+ * 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.
******************************************************************************/
package org.apache.olingo.odata2.fit.ref;
@@ -28,7 +28,7 @@ import org.junit.Test;
/**
* Read-only tests employing the reference scenario that use neither XML nor JSON
- *
+ *
*/
public class MiscReadOnlyTest extends AbstractRefTest {
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/b18130ac/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/PropertyJsonChangeTest.java
----------------------------------------------------------------------
diff --git a/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/PropertyJsonChangeTest.java b/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/PropertyJsonChangeTest.java
index b76f18c..e4cc3bd 100644
--- a/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/PropertyJsonChangeTest.java
+++ b/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/PropertyJsonChangeTest.java
@@ -1,20 +1,20 @@
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * 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
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * 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
+ * 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.
+ * 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.
******************************************************************************/
package org.apache.olingo.odata2.fit.ref;
@@ -27,7 +27,7 @@ import org.junit.Test;
/**
* Tests employing the reference scenario changing properties in JSON format.
- *
+ *
*/
public class PropertyJsonChangeTest extends AbstractRefTest {
@@ -52,7 +52,8 @@ public class PropertyJsonChangeTest extends AbstractRefTest {
putUri(url, "{\"Age\":\"17\"}", HttpContentType.APPLICATION_JSON, HttpStatusCodes.BAD_REQUEST);
final String urlForName = "Employees('2')/EmployeeName";
- putUri(urlForName, HttpContentType.APPLICATION_JSON, "{\"EmployeeName\":\"NewName\"}", HttpContentType.APPLICATION_JSON, HttpStatusCodes.NO_CONTENT);
+ putUri(urlForName, HttpContentType.APPLICATION_JSON, "{\"EmployeeName\":\"NewName\"}",
+ HttpContentType.APPLICATION_JSON, HttpStatusCodes.NO_CONTENT);
assertEquals("{\"d\":{\"EmployeeName\":\"NewName\"}}", getBody(callUri(urlForName + "?$format=json")));
putUri(urlForName, "{\"EmployeeName\":NewName}", HttpContentType.APPLICATION_JSON, HttpStatusCodes.BAD_REQUEST);
}
@@ -62,13 +63,14 @@ public class PropertyJsonChangeTest extends AbstractRefTest {
final String url = "Employees('2')/Age";
putUri(url, "", "{\"Age\":17}", HttpContentType.APPLICATION_JSON, HttpStatusCodes.NOT_ACCEPTABLE);
putUri(url, null, "{\"Age\":17}", HttpContentType.APPLICATION_JSON, HttpStatusCodes.NOT_ACCEPTABLE);
-
+
final String urlForName = "Employees('2')/EmployeeName";
- putUri(urlForName, "", "{\"EmployeeName\":\"NewName\"}", HttpContentType.APPLICATION_JSON, HttpStatusCodes.NOT_ACCEPTABLE);
- putUri(urlForName, null, "{\"EmployeeName\":\"NewName\"}", HttpContentType.APPLICATION_JSON, HttpStatusCodes.NOT_ACCEPTABLE);
+ putUri(urlForName, "", "{\"EmployeeName\":\"NewName\"}", HttpContentType.APPLICATION_JSON,
+ HttpStatusCodes.NOT_ACCEPTABLE);
+ putUri(urlForName, null, "{\"EmployeeName\":\"NewName\"}", HttpContentType.APPLICATION_JSON,
+ HttpStatusCodes.NOT_ACCEPTABLE);
}
-
@Test
public void complexProperty() throws Exception {
final String url1 = "Employees('2')/Location";
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/b18130ac/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/PropertyJsonReadOnlyTest.java
----------------------------------------------------------------------
diff --git a/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/PropertyJsonReadOnlyTest.java b/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/PropertyJsonReadOnlyTest.java
index 3d57223..d8f1710 100644
--- a/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/PropertyJsonReadOnlyTest.java
+++ b/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/PropertyJsonReadOnlyTest.java
@@ -1,33 +1,32 @@
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * 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
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * 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
+ * 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.
+ * 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.
******************************************************************************/
package org.apache.olingo.odata2.fit.ref;
import static org.junit.Assert.assertEquals;
import org.apache.http.HttpResponse;
-import org.junit.Test;
-
import org.apache.olingo.odata2.api.commons.HttpContentType;
+import org.junit.Test;
/**
* Tests employing the reference scenario reading properties in JSON format.
- *
+ *
*/
public class PropertyJsonReadOnlyTest extends AbstractRefTest {
@Test
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/b18130ac/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/PropertyXmlChangeTest.java
----------------------------------------------------------------------
diff --git a/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/PropertyXmlChangeTest.java b/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/PropertyXmlChangeTest.java
index b8bdca2..f14dbdd 100644
--- a/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/PropertyXmlChangeTest.java
+++ b/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/PropertyXmlChangeTest.java
@@ -1,36 +1,35 @@
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * 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
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * 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
+ * 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.
+ * 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.
******************************************************************************/
package org.apache.olingo.odata2.fit.ref;
import static org.custommonkey.xmlunit.XMLAssert.assertXpathEvaluatesTo;
import org.apache.http.HttpResponse;
-import org.junit.Test;
-
import org.apache.olingo.odata2.api.commons.HttpContentType;
import org.apache.olingo.odata2.api.commons.HttpStatusCodes;
import org.apache.olingo.odata2.api.commons.ODataHttpMethod;
import org.apache.olingo.odata2.api.edm.Edm;
+import org.junit.Test;
/**
* Tests employing the reference scenario changing properties in XML format
- *
+ *
*/
public class PropertyXmlChangeTest extends AbstractRefXmlTest {
@@ -53,7 +52,9 @@ public class PropertyXmlChangeTest extends AbstractRefXmlTest {
final String url4 = "Rooms('42')/Seats";
requestBody = "<Seats xmlns=\"" + Edm.NAMESPACE_D_2007_08 + "\">42</Seats>";
- HttpResponse response = callUri(ODataHttpMethod.PUT, url4, null, null, requestBody, HttpContentType.APPLICATION_XML_UTF8, HttpStatusCodes.NO_CONTENT);
+ HttpResponse response =
+ callUri(ODataHttpMethod.PUT, url4, null, null, requestBody, HttpContentType.APPLICATION_XML_UTF8,
+ HttpStatusCodes.NO_CONTENT);
checkEtag(response, "W/\"1\"");
final String url5 = "Employees('2')/EmployeeId";
@@ -74,7 +75,8 @@ public class PropertyXmlChangeTest extends AbstractRefXmlTest {
assertXpathEvaluatesTo("YYY", "/d:City/d:CityName", getBody(callUri(url2)));
requestBody = "<City xmlns=\"" + Edm.NAMESPACE_D_2007_08 + "\"><PostalCode>00000</PostalCode></City>";
- callUri(ODataHttpMethod.PATCH, url2, null, null, requestBody, HttpContentType.APPLICATION_XML, HttpStatusCodes.NO_CONTENT);
+ callUri(ODataHttpMethod.PATCH, url2, null, null, requestBody, HttpContentType.APPLICATION_XML,
+ HttpStatusCodes.NO_CONTENT);
assertXpathEvaluatesTo("YYY", "/d:City/d:CityName", getBody(callUri(url2)));
}
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/b18130ac/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/PropertyXmlReadOnlyTest.java
----------------------------------------------------------------------
diff --git a/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/PropertyXmlReadOnlyTest.java b/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/PropertyXmlReadOnlyTest.java
index 79fce6e..acc656e 100644
--- a/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/PropertyXmlReadOnlyTest.java
+++ b/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/PropertyXmlReadOnlyTest.java
@@ -1,20 +1,20 @@
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * 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
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * 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
+ * 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.
+ * 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.
******************************************************************************/
package org.apache.olingo.odata2.fit.ref;
@@ -24,15 +24,14 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import org.apache.http.HttpResponse;
-import org.junit.Test;
-
import org.apache.olingo.odata2.api.commons.HttpContentType;
import org.apache.olingo.odata2.api.commons.HttpHeaders;
import org.apache.olingo.odata2.api.commons.HttpStatusCodes;
+import org.junit.Test;
/**
* Tests employing the reference scenario reading properties in XML format.
- *
+ *
*/
public class PropertyXmlReadOnlyTest extends AbstractRefXmlTest {
@Test
@@ -70,8 +69,8 @@ public class PropertyXmlReadOnlyTest extends AbstractRefXmlTest {
response = callUri("Container2.Photos(Id=3,Type='image%2Fjpeg')/BinaryData/$value", HttpStatusCodes.NO_CONTENT);
assertNull(response.getEntity());
- // checkMediaType(response, IMAGE_JPEG);
- // assertEquals("", getBody(response));
+ // checkMediaType(response, IMAGE_JPEG);
+ // assertEquals("", getBody(response));
response = callUri("Container2.Photos(Id=3,Type='image%2Fjpeg')/BinaryData");
checkMediaType(response, HttpContentType.APPLICATION_XML_UTF8);
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/b18130ac/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/ServiceJsonTest.java
----------------------------------------------------------------------
diff --git a/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/ServiceJsonTest.java b/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/ServiceJsonTest.java
index d819c95..ab5bc07 100644
--- a/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/ServiceJsonTest.java
+++ b/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/ServiceJsonTest.java
@@ -1,20 +1,20 @@
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * 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
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * 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
+ * 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.
+ * 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.
******************************************************************************/
package org.apache.olingo.odata2.fit.ref;
@@ -25,18 +25,17 @@ import java.util.HashMap;
import java.util.Map;
import org.apache.http.HttpResponse;
-import org.custommonkey.xmlunit.SimpleNamespaceContext;
-import org.custommonkey.xmlunit.XMLUnit;
-import org.junit.Test;
-
import org.apache.olingo.odata2.api.commons.HttpContentType;
import org.apache.olingo.odata2.api.commons.HttpHeaders;
import org.apache.olingo.odata2.api.commons.HttpStatusCodes;
import org.apache.olingo.odata2.api.edm.Edm;
+import org.custommonkey.xmlunit.SimpleNamespaceContext;
+import org.custommonkey.xmlunit.XMLUnit;
+import org.junit.Test;
/**
* Tests employing the reference scenario reading the service document in JSON format.
- *
+ *
*/
public class ServiceJsonTest extends AbstractRefTest {
@Test
@@ -60,7 +59,9 @@ public class ServiceJsonTest extends AbstractRefTest {
@Test
public void serviceDocumentAcceptHeaderInvalidCharset() throws Exception {
- final HttpResponse response = callUri("", HttpHeaders.ACCEPT, HttpContentType.APPLICATION_XML + "; charset=iso-latin-1", HttpStatusCodes.NOT_ACCEPTABLE);
+ final HttpResponse response =
+ callUri("", HttpHeaders.ACCEPT, HttpContentType.APPLICATION_XML + "; charset=iso-latin-1",
+ HttpStatusCodes.NOT_ACCEPTABLE);
final String body = getBody(response);
Map<String, String> prefixMap = new HashMap<String, String>();
prefixMap.put("a", Edm.NAMESPACE_M_2007_08);
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/b18130ac/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/ServiceXmlTest.java
----------------------------------------------------------------------
diff --git a/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/ServiceXmlTest.java b/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/ServiceXmlTest.java
index 2a70fc0..15054d5 100644
--- a/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/ServiceXmlTest.java
+++ b/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/ServiceXmlTest.java
@@ -1,20 +1,20 @@
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * 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
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * 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
+ * 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.
+ * 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.
******************************************************************************/
package org.apache.olingo.odata2.fit.ref;
@@ -24,17 +24,16 @@ import static org.custommonkey.xmlunit.XMLAssert.assertXpathExists;
import java.io.IOException;
import org.apache.http.HttpResponse;
-import org.custommonkey.xmlunit.exceptions.XpathException;
-import org.junit.Test;
-import org.xml.sax.SAXException;
-
import org.apache.olingo.odata2.api.commons.HttpContentType;
import org.apache.olingo.odata2.api.commons.HttpHeaders;
import org.apache.olingo.odata2.api.commons.HttpStatusCodes;
+import org.custommonkey.xmlunit.exceptions.XpathException;
+import org.junit.Test;
+import org.xml.sax.SAXException;
/**
* Tests employing the reference scenario reading the service document in XML format
- *
+ *
*/
public class ServiceXmlTest extends AbstractRefXmlTest {
@@ -76,14 +75,16 @@ public class ServiceXmlTest extends AbstractRefXmlTest {
@Test
public void serviceDocumentAcceptHeaderAtom() throws Exception {
- final HttpResponse response = callUri("", HttpHeaders.ACCEPT, HttpContentType.APPLICATION_ATOM_XML, HttpStatusCodes.NOT_ACCEPTABLE);
+ final HttpResponse response =
+ callUri("", HttpHeaders.ACCEPT, HttpContentType.APPLICATION_ATOM_XML, HttpStatusCodes.NOT_ACCEPTABLE);
checkMediaType(response, HttpContentType.APPLICATION_XML);
validateXmlError(getBody(response));
}
@Test
public void serviceDocumentAcceptHeaderUtf8Atom() throws Exception {
- final HttpResponse response = callUri("", HttpHeaders.ACCEPT, HttpContentType.APPLICATION_ATOM_XML_UTF8, HttpStatusCodes.NOT_ACCEPTABLE);
+ final HttpResponse response =
+ callUri("", HttpHeaders.ACCEPT, HttpContentType.APPLICATION_ATOM_XML_UTF8, HttpStatusCodes.NOT_ACCEPTABLE);
checkMediaType(response, HttpContentType.APPLICATION_XML);
validateXmlError(getBody(response));
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/b18130ac/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/contentnegotiation/AbstractContentNegotiationTest.java
----------------------------------------------------------------------
diff --git a/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/contentnegotiation/AbstractContentNegotiationTest.java b/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/contentnegotiation/AbstractContentNegotiationTest.java
index 5e55b81..9deb593 100644
--- a/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/contentnegotiation/AbstractContentNegotiationTest.java
+++ b/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/contentnegotiation/AbstractContentNegotiationTest.java
@@ -1,20 +1,20 @@
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * 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
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * 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
+ * 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.
+ * 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.
******************************************************************************/
package org.apache.olingo.odata2.fit.ref.contentnegotiation;
@@ -43,8 +43,6 @@ import org.apache.http.client.methods.HttpRequestBase;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.log4j.Logger;
-import org.junit.Assert;
-
import org.apache.olingo.odata2.api.ODataService;
import org.apache.olingo.odata2.api.commons.HttpContentType;
import org.apache.olingo.odata2.api.commons.HttpHeaders;
@@ -61,6 +59,7 @@ import org.apache.olingo.odata2.ref.processor.ListsProcessor;
import org.apache.olingo.odata2.ref.processor.ScenarioDataSource;
import org.apache.olingo.odata2.testutil.fit.AbstractFitTest;
import org.apache.olingo.odata2.testutil.helper.StringHelper;
+import org.junit.Assert;
/**
*
@@ -196,7 +195,8 @@ public abstract class AbstractContentNegotiationTest extends AbstractFitTest {
}
public static FitTestSetBuilder create(final UriType uriType, final String path,
- final boolean defaultQueryOptions, final boolean defaultAcceptHeaders, final boolean defaultRequestContentTypeHeaders) {
+ final boolean defaultQueryOptions, final boolean defaultAcceptHeaders,
+ final boolean defaultRequestContentTypeHeaders) {
FitTestSetBuilder builder = new FitTestSetBuilder(new FitTestSet(uriType, path));
if (defaultQueryOptions) {
@@ -220,7 +220,8 @@ public abstract class AbstractContentNegotiationTest extends AbstractFitTest {
testParameters.add(fitTest);
}
- public void modifyRequestContentTypes(final List<String> requestContentTypes, final HttpStatusCodes expectedStatusCode, final String expectedContentType) {
+ public void modifyRequestContentTypes(final List<String> requestContentTypes,
+ final HttpStatusCodes expectedStatusCode, final String expectedContentType) {
FitTestSet fts = new FitTestSetBuilder(this)
.requestContentTypes(requestContentTypes)
.expectedStatusCode(expectedStatusCode)
@@ -228,11 +229,13 @@ public abstract class AbstractContentNegotiationTest extends AbstractFitTest {
replaceTestParameters(FitTest.create(fts));
}
- public void setTestParam(final List<String> acceptHeader, final HttpStatusCodes expectedStatusCode, final String expectedContentType) {
+ public void setTestParam(final List<String> acceptHeader, final HttpStatusCodes expectedStatusCode,
+ final String expectedContentType) {
setTestParam(queryOptions, acceptHeader, expectedStatusCode, expectedContentType);
}
- public void setTestParam(final List<String> queryOptions, final List<String> acceptHeader, final HttpStatusCodes expectedStatusCode, final String expectedContentType) {
+ public void setTestParam(final List<String> queryOptions, final List<String> acceptHeader,
+ final HttpStatusCodes expectedStatusCode, final String expectedContentType) {
List<FitTest> tp = FitTest.create(this, queryOptions, acceptHeader, expectedStatusCode, expectedContentType);
replaceTestParameters(tp);
}
@@ -243,9 +246,10 @@ public abstract class AbstractContentNegotiationTest extends AbstractFitTest {
}
/**
- * Execute all {@link FitTest}s with a default wait time between the calls (of {@value #DEFAULT_WAIT_BETWEEN_TESTCALLS_IN_MS} ms).
+ * Execute all {@link FitTest}s with a default wait time between the calls (of
+ * {@value #DEFAULT_WAIT_BETWEEN_TESTCALLS_IN_MS} ms).
*
- * For more information see @see #execute(URI, long)
+ * For more information see @see #execute(URI, long)
*
* @param serviceEndpoint
* @throws Exception
@@ -271,10 +275,10 @@ public abstract class AbstractContentNegotiationTest extends AbstractFitTest {
}
}
- // System.out.println("#########################################");
- // System.out.println("# Success: '" + successTests.size() + "', failed '" + test2Failure.size() +
- // "', total '" + testParameters.size() + "'.");
- // System.out.println("#########################################");
+ // System.out.println("#########################################");
+ // System.out.println("# Success: '" + successTests.size() + "', failed '" + test2Failure.size() +
+ // "', total '" + testParameters.size() + "'.");
+ // System.out.println("#########################################");
if (!test2Failure.isEmpty()) {
Set<Entry<FitTest, AssertionError>> failedTests = test2Failure.entrySet();
@@ -294,7 +298,8 @@ public abstract class AbstractContentNegotiationTest extends AbstractFitTest {
test = new FitTest(testSet);
}
- public FitTestBuilder(final UriType uriType, final String httpMethod, final String path, final HttpStatusCodes expectedStatusCode, final String expectedContentType) {
+ public FitTestBuilder(final UriType uriType, final String httpMethod, final String path,
+ final HttpStatusCodes expectedStatusCode, final String expectedContentType) {
test = new FitTest(uriType, httpMethod, path, expectedStatusCode, expectedContentType);
}
@@ -465,10 +470,12 @@ public abstract class AbstractContentNegotiationTest extends AbstractFitTest {
assertEquals("Unexpected status code for " + toString(), expectedStatusCode.getStatusCode(), resultStatusCode);
final String contentType = response.getFirstHeader(HttpHeaders.CONTENT_TYPE).getValue();
- assertEquals("Unexpected content type for " + toString(), ContentType.create(expectedContentType), ContentType.create(contentType));
+ assertEquals("Unexpected content type for " + toString(), ContentType.create(expectedContentType), ContentType
+ .create(contentType));
if (isContentExpected) {
- assertNotNull("Unexpected content for " + toString(), StringHelper.inputStreamToString(response.getEntity().getContent()));
+ assertNotNull("Unexpected content for " + toString(), StringHelper.inputStreamToString(response.getEntity()
+ .getContent()));
}
LOG.trace("Test passed [" + toString() + "]");
} finally {
@@ -488,7 +495,8 @@ public abstract class AbstractContentNegotiationTest extends AbstractFitTest {
return new FitTestBuilder(fitTestSet);
}
- public static FitTest create(final UriType uriType, final String httpMethod, final String path, final String queryOption, final String acceptHeader,
+ public static FitTest create(final UriType uriType, final String httpMethod, final String path,
+ final String queryOption, final String acceptHeader,
final String content, final String requestContentType,
final HttpStatusCodes expectedStatusCode, final String expectedContentType) {
@@ -526,7 +534,8 @@ public abstract class AbstractContentNegotiationTest extends AbstractFitTest {
return create(fitTestSet, acceptHeader2ContentType);
}
- public static List<FitTest> create(final FitTestSet fitTestSet, final Map<String, ContentType> acceptHeader2ContentType) {
+ public static List<FitTest> create(final FitTestSet fitTestSet,
+ final Map<String, ContentType> acceptHeader2ContentType) {
UriType uriType = fitTestSet.uriType;
String httpMethod = fitTestSet.httpMethod;
String path = fitTestSet.path;
@@ -543,7 +552,8 @@ public abstract class AbstractContentNegotiationTest extends AbstractFitTest {
/**
*
*/
- private static List<FitTest> create(final UriType uriType, final String httpMethod, final String path, final List<String> queryOptions,
+ private static List<FitTest> create(final UriType uriType, final String httpMethod, final String path,
+ final List<String> queryOptions,
final List<String> acceptHeaders, final Map<String, ContentType> acceptHeader2ContentType,
final String content, final List<String> requestContentTypeHeaders, final HttpStatusCodes expectedStatusCode) {
@@ -566,7 +576,8 @@ public abstract class AbstractContentNegotiationTest extends AbstractFitTest {
return testParameters;
}
- private static String getExpectedResponseContentType(final Map<String, ContentType> acceptHeader2ContentType, final String acceptHeader) {
+ private static String getExpectedResponseContentType(final Map<String, ContentType> acceptHeader2ContentType,
+ final String acceptHeader) {
String expectedContentType = null;
if (acceptHeader != null) {
ContentType tmpContentType = acceptHeader2ContentType.get(acceptHeader);
@@ -594,7 +605,7 @@ public abstract class AbstractContentNegotiationTest extends AbstractFitTest {
// first try read (GET)
if ("GET".equals(type)) {
request = new HttpGet(uri);
- } else { //then try write
+ } else { // then try write
HttpEntityEnclosingRequestBase writeRequest;
if ("POST".equals(type)) {
writeRequest = new HttpPost(uri);
@@ -683,7 +694,8 @@ public abstract class AbstractContentNegotiationTest extends AbstractFitTest {
}
public String toFullString() {
- return "FitTestRequest [type=" + type + ", requestUrl=" + requestUrl + ", headers=" + headers + ", content=\n{" + content + "\n}]";
+ return "FitTestRequest [type=" + type + ", requestUrl=" + requestUrl + ", headers=" + headers + ", content=\n{"
+ + content + "\n}]";
}
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/b18130ac/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/contentnegotiation/BasicContentNegotiationTest.java
----------------------------------------------------------------------
diff --git a/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/contentnegotiation/BasicContentNegotiationTest.java b/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/contentnegotiation/BasicContentNegotiationTest.java
index 460317d..16b8225 100644
--- a/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/contentnegotiation/BasicContentNegotiationTest.java
+++ b/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/contentnegotiation/BasicContentNegotiationTest.java
@@ -1,20 +1,20 @@
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * 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
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * 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
+ * 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.
+ * 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.
******************************************************************************/
package org.apache.olingo.odata2.fit.ref.contentnegotiation;
@@ -49,7 +49,7 @@ import org.junit.Test;
public class BasicContentNegotiationTest extends AbstractContentNegotiationTest {
private static final Logger LOG = Logger.getLogger(BasicContentNegotiationTest.class);
-
+
@Test
public void acceptHeaderAppAtomXml() throws Exception {
performRequestAndValidateResponseForAcceptHeader("Rooms('1')", APPLICATION_ATOM_XML, APPLICATION_ATOM_XML_UTF8);
@@ -70,58 +70,76 @@ public class BasicContentNegotiationTest extends AbstractContentNegotiationTest
@Test
public void acceptHeaderToContentTypeODataVerboseParameter() throws Exception {
final String parameter = ";odata=verbose";
- performRequestAndValidateResponseForAcceptHeader("Employees('1')", APPLICATION_JSON + parameter, APPLICATION_JSON + parameter);
- performRequestAndValidateResponseForAcceptHeader("Employees('1')", APPLICATION_JSON_UTF8 + parameter, APPLICATION_JSON_UTF8 + parameter);
- performRequestAndValidateResponseForAcceptHeader("Employees('1')/$count", APPLICATION_XML_UTF8 + parameter, TEXT_PLAIN_UTF8);
- performRequestAndValidateResponseForAcceptHeader("Employees('1')/$count", APPLICATION_JSON + parameter, TEXT_PLAIN_UTF8 );
- performRequestAndValidateResponseForAcceptHeader("Buildings('1')/$count", APPLICATION_XML_UTF8 + parameter, TEXT_PLAIN_UTF8);
- performRequestAndValidateResponseForAcceptHeader("Buildings('1')/$count", APPLICATION_JSON + parameter, TEXT_PLAIN_UTF8);
-
- performRequestAndValidateResponseForAcceptHeader("Employees/$count", APPLICATION_XML_UTF8 + parameter, TEXT_PLAIN_UTF8);
- performRequestAndValidateResponseForAcceptHeader("Employees/$count", APPLICATION_JSON + parameter, TEXT_PLAIN_UTF8 );
- performRequestAndValidateResponseForAcceptHeader("Buildings/$count", APPLICATION_XML_UTF8 + parameter, TEXT_PLAIN_UTF8);
+ performRequestAndValidateResponseForAcceptHeader("Employees('1')", APPLICATION_JSON + parameter, APPLICATION_JSON
+ + parameter);
+ performRequestAndValidateResponseForAcceptHeader("Employees('1')", APPLICATION_JSON_UTF8 + parameter,
+ APPLICATION_JSON_UTF8 + parameter);
+ performRequestAndValidateResponseForAcceptHeader("Employees('1')/$count", APPLICATION_XML_UTF8 + parameter,
+ TEXT_PLAIN_UTF8);
+ performRequestAndValidateResponseForAcceptHeader("Employees('1')/$count", APPLICATION_JSON + parameter,
+ TEXT_PLAIN_UTF8);
+ performRequestAndValidateResponseForAcceptHeader("Buildings('1')/$count", APPLICATION_XML_UTF8 + parameter,
+ TEXT_PLAIN_UTF8);
+ performRequestAndValidateResponseForAcceptHeader("Buildings('1')/$count", APPLICATION_JSON + parameter,
+ TEXT_PLAIN_UTF8);
+
+ performRequestAndValidateResponseForAcceptHeader("Employees/$count", APPLICATION_XML_UTF8 + parameter,
+ TEXT_PLAIN_UTF8);
+ performRequestAndValidateResponseForAcceptHeader("Employees/$count", APPLICATION_JSON + parameter, TEXT_PLAIN_UTF8);
+ performRequestAndValidateResponseForAcceptHeader("Buildings/$count", APPLICATION_XML_UTF8 + parameter,
+ TEXT_PLAIN_UTF8);
performRequestAndValidateResponseForAcceptHeader("Buildings/$count", APPLICATION_JSON + parameter, TEXT_PLAIN_UTF8);
}
@Test
public void acceptHeaderToContentTypeIgnoredAcceptHeaders() throws Exception {
performRequestAndValidateResponseForAcceptHeader("Employees('1')/$count", APPLICATION_XML_UTF8, TEXT_PLAIN_UTF8);
- performRequestAndValidateResponseForAcceptHeader("Employees('1')/$count", APPLICATION_JSON, TEXT_PLAIN_UTF8 );
+ performRequestAndValidateResponseForAcceptHeader("Employees('1')/$count", APPLICATION_JSON, TEXT_PLAIN_UTF8);
performRequestAndValidateResponseForAcceptHeader("Buildings('1')/$count", APPLICATION_XML_UTF8, TEXT_PLAIN_UTF8);
performRequestAndValidateResponseForAcceptHeader("Buildings('1')/$count", APPLICATION_JSON, TEXT_PLAIN_UTF8);
performRequestAndValidateResponseForAcceptHeader("Buildings('1')/$count", TEXT_PLAIN_UTF8, TEXT_PLAIN_UTF8);
performRequestAndValidateResponseForAcceptHeader("Buildings('1')/$count", TEXT_PLAIN, TEXT_PLAIN_UTF8);
performRequestAndValidateResponseForAcceptHeader("Employees/$count", APPLICATION_XML_UTF8, TEXT_PLAIN_UTF8);
- performRequestAndValidateResponseForAcceptHeader("Employees/$count", APPLICATION_JSON, TEXT_PLAIN_UTF8 );
+ performRequestAndValidateResponseForAcceptHeader("Employees/$count", APPLICATION_JSON, TEXT_PLAIN_UTF8);
performRequestAndValidateResponseForAcceptHeader("Buildings/$count", APPLICATION_XML_UTF8, TEXT_PLAIN_UTF8);
performRequestAndValidateResponseForAcceptHeader("Buildings/$count", APPLICATION_JSON, TEXT_PLAIN_UTF8);
performRequestAndValidateResponseForAcceptHeader("Buildings/$count", TEXT_PLAIN_UTF8, TEXT_PLAIN_UTF8);
performRequestAndValidateResponseForAcceptHeader("Buildings/$count", TEXT_PLAIN, TEXT_PLAIN_UTF8);
final String parameter = ";someUnknownParameter=withAValue";
- performRequestAndValidateResponseForAcceptHeader("Employees('1')/$count", APPLICATION_XML_UTF8 + parameter, TEXT_PLAIN_UTF8);
- performRequestAndValidateResponseForAcceptHeader("Employees('1')/$count", APPLICATION_JSON + parameter, TEXT_PLAIN_UTF8 );
- performRequestAndValidateResponseForAcceptHeader("Buildings('1')/$count", APPLICATION_XML_UTF8 + parameter, TEXT_PLAIN_UTF8);
- performRequestAndValidateResponseForAcceptHeader("Buildings('1')/$count", APPLICATION_JSON + parameter, TEXT_PLAIN_UTF8);
-
- performRequestAndValidateResponseForAcceptHeader("Employees/$count", APPLICATION_XML_UTF8 + parameter, TEXT_PLAIN_UTF8);
- performRequestAndValidateResponseForAcceptHeader("Employees/$count", APPLICATION_JSON + parameter, TEXT_PLAIN_UTF8 );
- performRequestAndValidateResponseForAcceptHeader("Buildings/$count", APPLICATION_XML_UTF8 + parameter, TEXT_PLAIN_UTF8);
+ performRequestAndValidateResponseForAcceptHeader("Employees('1')/$count", APPLICATION_XML_UTF8 + parameter,
+ TEXT_PLAIN_UTF8);
+ performRequestAndValidateResponseForAcceptHeader("Employees('1')/$count", APPLICATION_JSON + parameter,
+ TEXT_PLAIN_UTF8);
+ performRequestAndValidateResponseForAcceptHeader("Buildings('1')/$count", APPLICATION_XML_UTF8 + parameter,
+ TEXT_PLAIN_UTF8);
+ performRequestAndValidateResponseForAcceptHeader("Buildings('1')/$count", APPLICATION_JSON + parameter,
+ TEXT_PLAIN_UTF8);
+
+ performRequestAndValidateResponseForAcceptHeader("Employees/$count", APPLICATION_XML_UTF8 + parameter,
+ TEXT_PLAIN_UTF8);
+ performRequestAndValidateResponseForAcceptHeader("Employees/$count", APPLICATION_JSON + parameter, TEXT_PLAIN_UTF8);
+ performRequestAndValidateResponseForAcceptHeader("Buildings/$count", APPLICATION_XML_UTF8 + parameter,
+ TEXT_PLAIN_UTF8);
performRequestAndValidateResponseForAcceptHeader("Buildings/$count", APPLICATION_JSON + parameter, TEXT_PLAIN_UTF8);
}
@Test
public void acceptHeaderToContentTypeIgnoredAcceptHeadersValue() throws Exception {
final String expectedImageContentType = "image/jpeg";
- performRequestAndValidateResponseForAcceptHeader("Employees('1')/$value", APPLICATION_XML_UTF8, expectedImageContentType);
- performRequestAndValidateResponseForAcceptHeader("Employees('1')/$value", APPLICATION_JSON, expectedImageContentType);
+ performRequestAndValidateResponseForAcceptHeader("Employees('1')/$value", APPLICATION_XML_UTF8,
+ expectedImageContentType);
+ performRequestAndValidateResponseForAcceptHeader("Employees('1')/$value", APPLICATION_JSON,
+ expectedImageContentType);
final String expectedTextContentType = "text/plain;charset=utf-8";
- performRequestAndValidateResponseForAcceptHeader("Employees('1')/Age/$value", APPLICATION_XML_UTF8, expectedTextContentType);
- performRequestAndValidateResponseForAcceptHeader("Employees('1')/Age/$value", APPLICATION_JSON, expectedTextContentType);
+ performRequestAndValidateResponseForAcceptHeader("Employees('1')/Age/$value", APPLICATION_XML_UTF8,
+ expectedTextContentType);
+ performRequestAndValidateResponseForAcceptHeader("Employees('1')/Age/$value", APPLICATION_JSON,
+ expectedTextContentType);
}
-
+
@Test
public void acceptHeaderToContentTypeNotAcceptable() throws Exception {
final String parameterUnknown = ";someUnknownParameter=withAValue";
@@ -139,7 +157,9 @@ public class BasicContentNegotiationTest extends AbstractContentNegotiationTest
* @throws IOException
* @throws ClientProtocolException
*/
- private void performRequestAndValidateResponseForAcceptHeader(String endPointPostfix, String requestAcceptHeader, String expectedResponseContentType) throws IOException, ClientProtocolException {
+ private void performRequestAndValidateResponseForAcceptHeader(final String endPointPostfix,
+ final String requestAcceptHeader, final String expectedResponseContentType) throws IOException,
+ ClientProtocolException {
HttpGet get = new HttpGet(URI.create(getEndpoint() + endPointPostfix));
get.setHeader(HttpHeaders.ACCEPT, requestAcceptHeader);
final HttpResponse response = new DefaultHttpClient().execute(get);
@@ -150,12 +170,12 @@ public class BasicContentNegotiationTest extends AbstractContentNegotiationTest
assertEquals(ContentType.create(expectedResponseContentType), ContentType.create(contentType));
assertNotNull(StringHelper.inputStreamToString(response.getEntity().getContent()));
} catch (AssertionError e) {
- LOG.debug("Response: \n#############\n#\n\n" +
- StringHelper.inputStreamToString(response.getEntity().getContent()) + "\n\n#\n####################");
+ LOG.debug("Response: \n#############\n#\n\n" +
+ StringHelper.inputStreamToString(response.getEntity().getContent()) + "\n\n#\n####################");
throw e;
}
}
-
+
/**
*
* @param endPointPostfix
@@ -164,7 +184,8 @@ public class BasicContentNegotiationTest extends AbstractContentNegotiationTest
* @throws IOException
* @throws ClientProtocolException
*/
- private void performRequestAndValidateResponseForNotAcceptable(String endPointPostfix, String requestAcceptHeader) throws IOException, ClientProtocolException {
+ private void performRequestAndValidateResponseForNotAcceptable(final String endPointPostfix,
+ final String requestAcceptHeader) throws IOException, ClientProtocolException {
HttpGet get = new HttpGet(URI.create(getEndpoint() + endPointPostfix));
get.setHeader(HttpHeaders.ACCEPT, requestAcceptHeader);
final HttpResponse response = new DefaultHttpClient().execute(get);
@@ -172,12 +193,12 @@ public class BasicContentNegotiationTest extends AbstractContentNegotiationTest
final String contentType = response.getFirstHeader(HttpHeaders.CONTENT_TYPE).getValue();
// assertEquals(expectedResponseContentType, contentType);
try {
-
+
assertEquals(ContentType.APPLICATION_XML, ContentType.create(contentType));
assertNotNull(StringHelper.inputStreamToString(response.getEntity().getContent()));
} catch (AssertionError e) {
- LOG.debug("Response: \n#############\n#\n\n" +
- StringHelper.inputStreamToString(response.getEntity().getContent()) + "\n\n#\n####################");
+ LOG.debug("Response: \n#############\n#\n\n" +
+ StringHelper.inputStreamToString(response.getEntity().getContent()) + "\n\n#\n####################");
throw e;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/b18130ac/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/contentnegotiation/ContentNegotiationGetRequestTest.java
----------------------------------------------------------------------
diff --git a/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/contentnegotiation/ContentNegotiationGetRequestTest.java b/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/contentnegotiation/ContentNegotiationGetRequestTest.java
index 8c3c92e..43feebc 100644
--- a/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/contentnegotiation/ContentNegotiationGetRequestTest.java
+++ b/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/contentnegotiation/ContentNegotiationGetRequestTest.java
@@ -1,20 +1,20 @@
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * 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
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * 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
+ * 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.
+ * 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.
******************************************************************************/
package org.apache.olingo.odata2.fit.ref.contentnegotiation;
@@ -28,15 +28,14 @@ import java.util.List;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
-import org.junit.Ignore;
-import org.junit.Test;
-
import org.apache.olingo.odata2.api.commons.HttpContentType;
import org.apache.olingo.odata2.api.commons.HttpHeaders;
import org.apache.olingo.odata2.api.commons.HttpStatusCodes;
import org.apache.olingo.odata2.core.commons.ContentType;
import org.apache.olingo.odata2.core.uri.UriType;
import org.apache.olingo.odata2.testutil.helper.StringHelper;
+import org.junit.Ignore;
+import org.junit.Test;
/**
*
@@ -88,10 +87,14 @@ public class ContentNegotiationGetRequestTest extends AbstractContentNegotiation
FitTestSet testSet = FitTestSet.create(UriType.URI0, "/").init();
// set specific response 'Content-Type's for '$format'
- testSet.setTestParam(Arrays.asList("?$format=xml"), ACCEPT_HEADER_VALUES, HttpStatusCodes.OK, "application/xml; charset=utf-8");
- testSet.setTestParam(Arrays.asList("?$format=atom"), ACCEPT_HEADER_VALUES, HttpStatusCodes.OK, "application/atomsvc+xml; charset=utf-8");
- testSet.setTestParam(Arrays.asList("?$format=json"), ACCEPT_HEADER_VALUES, HttpStatusCodes.OK, HttpContentType.APPLICATION_JSON_UTF8);
- testSet.setTestParam(Arrays.asList(""), Arrays.asList(""), HttpStatusCodes.OK, "application/atomsvc+xml; charset=utf-8");
+ testSet.setTestParam(Arrays.asList("?$format=xml"), ACCEPT_HEADER_VALUES, HttpStatusCodes.OK,
+ "application/xml; charset=utf-8");
+ testSet.setTestParam(Arrays.asList("?$format=atom"), ACCEPT_HEADER_VALUES, HttpStatusCodes.OK,
+ "application/atomsvc+xml; charset=utf-8");
+ testSet.setTestParam(Arrays.asList("?$format=json"), ACCEPT_HEADER_VALUES, HttpStatusCodes.OK,
+ HttpContentType.APPLICATION_JSON_UTF8);
+ testSet.setTestParam(Arrays.asList(""), Arrays.asList(""), HttpStatusCodes.OK,
+ "application/atomsvc+xml; charset=utf-8");
// set all 'NOT ACCEPTED' requests
final List<String> notAcceptedHeaderValues = Arrays.asList(
@@ -103,7 +106,8 @@ public class ContentNegotiationGetRequestTest extends AbstractContentNegotiation
testSet.setTestParam(Arrays.asList(""), notAcceptedHeaderValues, HttpStatusCodes.NOT_ACCEPTABLE, "application/xml");
final List<String> notAcceptedJsonHeaderValues = Arrays.asList("application/json; charset=utf-8");
- testSet.setTestParam(Arrays.asList("", "?$format=json"), notAcceptedJsonHeaderValues, HttpStatusCodes.NOT_ACCEPTABLE, "application/json");
+ testSet.setTestParam(Arrays.asList("", "?$format=json"), notAcceptedJsonHeaderValues,
+ HttpStatusCodes.NOT_ACCEPTABLE, "application/json");
// execute all defined tests
testSet.execute(getEndpoint());
@@ -115,10 +119,14 @@ public class ContentNegotiationGetRequestTest extends AbstractContentNegotiation
FitTestSet testSet = FitTestSet.create(UriType.URI1, "/Employees").init();
// set specific response 'Content-Type's for '$format'
- testSet.setTestParam(Arrays.asList("?$format=xml"), ACCEPT_HEADER_VALUES, HttpStatusCodes.OK, "application/xml; charset=utf-8");
- testSet.setTestParam(Arrays.asList("?$format=atom"), ACCEPT_HEADER_VALUES, HttpStatusCodes.OK, "application/atom+xml; type=feed; charset=utf-8");
- testSet.setTestParam(Arrays.asList("?$format=json"), ACCEPT_HEADER_VALUES, HttpStatusCodes.OK, HttpContentType.APPLICATION_JSON);
- testSet.setTestParam(Arrays.asList(""), Arrays.asList("", "application/atom+xml", "application/atom+xml; charset=utf-8"),
+ testSet.setTestParam(Arrays.asList("?$format=xml"), ACCEPT_HEADER_VALUES, HttpStatusCodes.OK,
+ "application/xml; charset=utf-8");
+ testSet.setTestParam(Arrays.asList("?$format=atom"), ACCEPT_HEADER_VALUES, HttpStatusCodes.OK,
+ "application/atom+xml; type=feed; charset=utf-8");
+ testSet.setTestParam(Arrays.asList("?$format=json"), ACCEPT_HEADER_VALUES, HttpStatusCodes.OK,
+ HttpContentType.APPLICATION_JSON);
+ testSet.setTestParam(Arrays.asList(""), Arrays.asList("", "application/atom+xml",
+ "application/atom+xml; charset=utf-8"),
HttpStatusCodes.OK, "application/atom+xml; type=feed; charset=utf-8");
// set all 'NOT ACCEPTED' requests
@@ -132,7 +140,8 @@ public class ContentNegotiationGetRequestTest extends AbstractContentNegotiation
final List<String> notAcceptedJsonHeaderValues = Arrays.asList("application/json; charset=utf-8");
// TODO: check which behavior is currently wanted
- testSet.setTestParam(Arrays.asList("", "?$format=json"), notAcceptedJsonHeaderValues, HttpStatusCodes.NOT_ACCEPTABLE, "application/json");
+ testSet.setTestParam(Arrays.asList("", "?$format=json"), notAcceptedJsonHeaderValues,
+ HttpStatusCodes.NOT_ACCEPTABLE, "application/json");
// execute all defined tests
testSet.execute(getEndpoint());
@@ -144,9 +153,12 @@ public class ContentNegotiationGetRequestTest extends AbstractContentNegotiation
FitTestSet testSet = FitTestSet.create(UriType.URI2, "/Employees('1')").init();
// set specific response 'Content-Type's for '$format'
- testSet.setTestParam(Arrays.asList("?$format=xml"), ACCEPT_HEADER_VALUES, HttpStatusCodes.OK, "application/xml; charset=utf-8");
- testSet.setTestParam(Arrays.asList("?$format=atom"), ACCEPT_HEADER_VALUES, HttpStatusCodes.OK, "application/atom+xml; type=entry; charset=utf-8");
- testSet.setTestParam(Arrays.asList(""), Arrays.asList("", "application/atom+xml", "application/atom+xml; charset=utf-8"),
+ testSet.setTestParam(Arrays.asList("?$format=xml"), ACCEPT_HEADER_VALUES, HttpStatusCodes.OK,
+ "application/xml; charset=utf-8");
+ testSet.setTestParam(Arrays.asList("?$format=atom"), ACCEPT_HEADER_VALUES, HttpStatusCodes.OK,
+ "application/atom+xml; type=entry; charset=utf-8");
+ testSet.setTestParam(Arrays.asList(""), Arrays.asList("", "application/atom+xml",
+ "application/atom+xml; charset=utf-8"),
HttpStatusCodes.OK, "application/atom+xml; type=entry; charset=utf-8");
// set all 'NOT ACCEPTED' requests
@@ -164,8 +176,10 @@ public class ContentNegotiationGetRequestTest extends AbstractContentNegotiation
"application/json; charset=utf-8"
);
// TODO: check which behavior is currently wanted
- testSet.setTestParam(Arrays.asList("?$format=json"), ACCEPT_HEADER_VALUES, HttpStatusCodes.NOT_ACCEPTABLE, "application/xml");
- testSet.setTestParam(Arrays.asList("", "?$format=json"), notAcceptedJsonHeaderValues, HttpStatusCodes.NOT_ACCEPTABLE, "application/json");
+ testSet.setTestParam(Arrays.asList("?$format=json"), ACCEPT_HEADER_VALUES, HttpStatusCodes.NOT_ACCEPTABLE,
+ "application/xml");
+ testSet.setTestParam(Arrays.asList("", "?$format=json"), notAcceptedJsonHeaderValues,
+ HttpStatusCodes.NOT_ACCEPTABLE, "application/json");
// execute all defined tests
testSet.execute(getEndpoint());
@@ -177,7 +191,8 @@ public class ContentNegotiationGetRequestTest extends AbstractContentNegotiation
FitTestSet testSet = FitTestSet.create(UriType.URI3, "/Employees('1')/Location").init();
// set specific response 'Content-Type's for '$format'
- testSet.setTestParam(Arrays.asList("?$format=xml"), ACCEPT_HEADER_VALUES, HttpStatusCodes.OK, "application/xml; charset=utf-8");
+ testSet.setTestParam(Arrays.asList("?$format=xml"), ACCEPT_HEADER_VALUES, HttpStatusCodes.OK,
+ "application/xml; charset=utf-8");
testSet.setTestParam(Arrays.asList(""), Arrays.asList(""), HttpStatusCodes.OK, "application/xml; charset=utf-8");
// set all 'NOT ACCEPTED' requests
@@ -191,7 +206,8 @@ public class ContentNegotiationGetRequestTest extends AbstractContentNegotiation
);
testSet.setTestParam(Arrays.asList(""), notAcceptedHeaderValues, HttpStatusCodes.NOT_ACCEPTABLE, "application/xml");
// '$format=atom' it not allowed
- testSet.setTestParam(Arrays.asList("?$format=atom"), ACCEPT_HEADER_VALUES, HttpStatusCodes.NOT_ACCEPTABLE, "application/xml");
+ testSet.setTestParam(Arrays.asList("?$format=atom"), ACCEPT_HEADER_VALUES, HttpStatusCodes.NOT_ACCEPTABLE,
+ "application/xml");
// JSON is not supported
final List<String> notAcceptedJsonHeaderValues = Arrays.asList(
@@ -199,8 +215,10 @@ public class ContentNegotiationGetRequestTest extends AbstractContentNegotiation
"application/json; charset=utf-8"
);
// TODO: check which behavior is currently wanted
- testSet.setTestParam(Arrays.asList("?$format=json"), ACCEPT_HEADER_VALUES, HttpStatusCodes.NOT_ACCEPTABLE, "application/xml");
- testSet.setTestParam(Arrays.asList("", "?$format=json", "?$format=atom"), notAcceptedJsonHeaderValues, HttpStatusCodes.NOT_ACCEPTABLE, "application/json");
+ testSet.setTestParam(Arrays.asList("?$format=json"), ACCEPT_HEADER_VALUES, HttpStatusCodes.NOT_ACCEPTABLE,
+ "application/xml");
+ testSet.setTestParam(Arrays.asList("", "?$format=json", "?$format=atom"), notAcceptedJsonHeaderValues,
+ HttpStatusCodes.NOT_ACCEPTABLE, "application/json");
// execute all defined tests
testSet.execute(getEndpoint());
@@ -212,7 +230,8 @@ public class ContentNegotiationGetRequestTest extends AbstractContentNegotiation
FitTestSet testSet = FitTestSet.create(UriType.URI4, "/Employees('1')/Location/Country").init();
// set specific response 'Content-Type's for '$format'
- testSet.setTestParam(Arrays.asList("?$format=xml"), ACCEPT_HEADER_VALUES, HttpStatusCodes.OK, "application/xml; charset=utf-8");
+ testSet.setTestParam(Arrays.asList("?$format=xml"), ACCEPT_HEADER_VALUES, HttpStatusCodes.OK,
+ "application/xml; charset=utf-8");
testSet.setTestParam(Arrays.asList(""), Arrays.asList(""), HttpStatusCodes.OK, "application/xml; charset=utf-8");
// set all 'NOT ACCEPTED' requests
@@ -226,7 +245,8 @@ public class ContentNegotiationGetRequestTest extends AbstractContentNegotiation
);
testSet.setTestParam(Arrays.asList(""), notAcceptedHeaderValues, HttpStatusCodes.NOT_ACCEPTABLE, "application/xml");
// '$format=atom' it not allowed
- testSet.setTestParam(Arrays.asList("?$format=atom"), ACCEPT_HEADER_VALUES, HttpStatusCodes.NOT_ACCEPTABLE, "application/xml");
+ testSet.setTestParam(Arrays.asList("?$format=atom"), ACCEPT_HEADER_VALUES, HttpStatusCodes.NOT_ACCEPTABLE,
+ "application/xml");
// JSON is not supported
final List<String> notAcceptedJsonHeaderValues = Arrays.asList(
@@ -234,8 +254,10 @@ public class ContentNegotiationGetRequestTest extends AbstractContentNegotiation
"application/json; charset=utf-8"
);
// TODO: check which behavior is currently wanted
- testSet.setTestParam(Arrays.asList("?$format=json"), ACCEPT_HEADER_VALUES, HttpStatusCodes.NOT_ACCEPTABLE, "application/xml");
- testSet.setTestParam(Arrays.asList("", "?$format=json", "?$format=atom"), notAcceptedJsonHeaderValues, HttpStatusCodes.NOT_ACCEPTABLE, "application/json");
+ testSet.setTestParam(Arrays.asList("?$format=json"), ACCEPT_HEADER_VALUES, HttpStatusCodes.NOT_ACCEPTABLE,
+ "application/xml");
+ testSet.setTestParam(Arrays.asList("", "?$format=json", "?$format=atom"), notAcceptedJsonHeaderValues,
+ HttpStatusCodes.NOT_ACCEPTABLE, "application/json");
// execute all defined tests
testSet.execute(getEndpoint());
@@ -247,7 +269,8 @@ public class ContentNegotiationGetRequestTest extends AbstractContentNegotiation
FitTestSet testSet = FitTestSet.create(UriType.URI4, "/Employees('1')/Age").init();
// set specific response 'Content-Type's for '$format'
- testSet.setTestParam(Arrays.asList("?$format=xml"), ACCEPT_HEADER_VALUES, HttpStatusCodes.OK, "application/xml; charset=utf-8");
+ testSet.setTestParam(Arrays.asList("?$format=xml"), ACCEPT_HEADER_VALUES, HttpStatusCodes.OK,
+ "application/xml; charset=utf-8");
testSet.setTestParam(Arrays.asList(""), Arrays.asList(""), HttpStatusCodes.OK, "application/xml; charset=utf-8");
// set all 'NOT ACCEPTED' requests
@@ -261,7 +284,8 @@ public class ContentNegotiationGetRequestTest extends AbstractContentNegotiation
);
testSet.setTestParam(Arrays.asList(""), notAcceptedHeaderValues, HttpStatusCodes.NOT_ACCEPTABLE, "application/xml");
// '$format=atom' it not allowed
- testSet.setTestParam(Arrays.asList("?$format=atom"), ACCEPT_HEADER_VALUES, HttpStatusCodes.NOT_ACCEPTABLE, "application/xml");
+ testSet.setTestParam(Arrays.asList("?$format=atom"), ACCEPT_HEADER_VALUES, HttpStatusCodes.NOT_ACCEPTABLE,
+ "application/xml");
// JSON is not supported
final List<String> notAcceptedJsonHeaderValues = Arrays.asList(
@@ -269,8 +293,10 @@ public class ContentNegotiationGetRequestTest extends AbstractContentNegotiation
"application/json; charset=utf-8"
);
// TODO: check which behavior is currently wanted
- testSet.setTestParam(Arrays.asList("?$format=json"), ACCEPT_HEADER_VALUES, HttpStatusCodes.NOT_ACCEPTABLE, "application/xml");
- testSet.setTestParam(Arrays.asList("", "?$format=json", "?$format=atom"), notAcceptedJsonHeaderValues, HttpStatusCodes.NOT_ACCEPTABLE, "application/json");
+ testSet.setTestParam(Arrays.asList("?$format=json"), ACCEPT_HEADER_VALUES, HttpStatusCodes.NOT_ACCEPTABLE,
+ "application/xml");
+ testSet.setTestParam(Arrays.asList("", "?$format=json", "?$format=atom"), notAcceptedJsonHeaderValues,
+ HttpStatusCodes.NOT_ACCEPTABLE, "application/json");
// execute all defined tests
testSet.execute(getEndpoint());
@@ -282,9 +308,12 @@ public class ContentNegotiationGetRequestTest extends AbstractContentNegotiation
FitTestSet testSet = FitTestSet.create(UriType.URI6A, "/Employees('1')/ne_Room").init();
// set specific response 'Content-Type's for '$format'
- testSet.setTestParam(Arrays.asList("?$format=xml"), ACCEPT_HEADER_VALUES, HttpStatusCodes.OK, "application/xml; charset=utf-8");
- testSet.setTestParam(Arrays.asList("?$format=atom"), ACCEPT_HEADER_VALUES, HttpStatusCodes.OK, "application/atom+xml; type=entry; charset=utf-8");
- testSet.setTestParam(Arrays.asList(""), Arrays.asList("", "application/atom+xml", "application/atom+xml; charset=utf-8"),
+ testSet.setTestParam(Arrays.asList("?$format=xml"), ACCEPT_HEADER_VALUES, HttpStatusCodes.OK,
+ "application/xml; charset=utf-8");
+ testSet.setTestParam(Arrays.asList("?$format=atom"), ACCEPT_HEADER_VALUES, HttpStatusCodes.OK,
+ "application/atom+xml; type=entry; charset=utf-8");
+ testSet.setTestParam(Arrays.asList(""), Arrays.asList("", "application/atom+xml",
+ "application/atom+xml; charset=utf-8"),
HttpStatusCodes.OK, "application/atom+xml; type=entry; charset=utf-8");
// set all 'NOT ACCEPTED' requests
@@ -302,8 +331,10 @@ public class ContentNegotiationGetRequestTest extends AbstractContentNegotiation
"application/json; charset=utf-8"
);
// TODO: check which behavior is currently wanted
- testSet.setTestParam(Arrays.asList("?$format=json"), ACCEPT_HEADER_VALUES, HttpStatusCodes.NOT_ACCEPTABLE, "application/xml");
- testSet.setTestParam(Arrays.asList("", "?$format=json"), notAcceptedJsonHeaderValues, HttpStatusCodes.NOT_ACCEPTABLE, "application/json");
+ testSet.setTestParam(Arrays.asList("?$format=json"), ACCEPT_HEADER_VALUES, HttpStatusCodes.NOT_ACCEPTABLE,
+ "application/xml");
+ testSet.setTestParam(Arrays.asList("", "?$format=json"), notAcceptedJsonHeaderValues,
+ HttpStatusCodes.NOT_ACCEPTABLE, "application/json");
// execute all defined tests
testSet.execute(getEndpoint());
@@ -315,7 +346,8 @@ public class ContentNegotiationGetRequestTest extends AbstractContentNegotiation
FitTestSet testSet = FitTestSet.create(UriType.URI7A, "/Employees('1')/$links/ne_Room").init();
// set specific response 'Content-Type's for '$format'
- testSet.setTestParam(Arrays.asList("?$format=xml"), ACCEPT_HEADER_VALUES, HttpStatusCodes.OK, "application/xml; charset=utf-8");
+ testSet.setTestParam(Arrays.asList("?$format=xml"), ACCEPT_HEADER_VALUES, HttpStatusCodes.OK,
+ "application/xml; charset=utf-8");
testSet.setTestParam(Arrays.asList(""), Arrays.asList(""), HttpStatusCodes.OK, "application/xml; charset=utf-8");
// set all 'NOT ACCEPTED' requests
@@ -335,8 +367,10 @@ public class ContentNegotiationGetRequestTest extends AbstractContentNegotiation
"application/json; charset=utf-8"
);
// TODO: check which behavior is currently wanted
- testSet.setTestParam(Arrays.asList("?$format=json", "?$format=atom"), ACCEPT_HEADER_VALUES, HttpStatusCodes.NOT_ACCEPTABLE, "application/xml");
- testSet.setTestParam(Arrays.asList("", "?$format=json", "?$format=atom"), notAcceptedJsonHeaderValues, HttpStatusCodes.NOT_ACCEPTABLE, "application/json");
+ testSet.setTestParam(Arrays.asList("?$format=json", "?$format=atom"), ACCEPT_HEADER_VALUES,
+ HttpStatusCodes.NOT_ACCEPTABLE, "application/xml");
+ testSet.setTestParam(Arrays.asList("", "?$format=json", "?$format=atom"), notAcceptedJsonHeaderValues,
+ HttpStatusCodes.NOT_ACCEPTABLE, "application/json");
// execute all defined tests
testSet.execute(getEndpoint());
@@ -363,14 +397,16 @@ public class ContentNegotiationGetRequestTest extends AbstractContentNegotiation
testSet.setTestParam(Arrays.asList(""), notAcceptedHeaderValues, HttpStatusCodes.NOT_ACCEPTABLE, "application/xml");
// every combination of $format and $metadata is a 'BAD REQUEST'
- testSet.setTestParam(Arrays.asList("?$format=json", "?$format=xml", "?$format=atom"), ACCEPT_HEADER_VALUES, HttpStatusCodes.BAD_REQUEST, "application/xml");
+ testSet.setTestParam(Arrays.asList("?$format=json", "?$format=xml", "?$format=atom"), ACCEPT_HEADER_VALUES,
+ HttpStatusCodes.BAD_REQUEST, "application/xml");
//
final List<String> jsonAcceptHeaders = Arrays.asList(
"application/json",
"application/json; charset=utf-8"
);
// TODO: check which behavior is currently wanted
- testSet.setTestParam(Arrays.asList("?$format=json", "?$format=xml", "?$format=atom"), jsonAcceptHeaders, HttpStatusCodes.BAD_REQUEST, "application/json");
+ testSet.setTestParam(Arrays.asList("?$format=json", "?$format=xml", "?$format=atom"), jsonAcceptHeaders,
+ HttpStatusCodes.BAD_REQUEST, "application/json");
testSet.setTestParam(Arrays.asList(""), jsonAcceptHeaders, HttpStatusCodes.NOT_ACCEPTABLE, "application/json");
// execute all defined tests
@@ -381,17 +417,21 @@ public class ContentNegotiationGetRequestTest extends AbstractContentNegotiation
@Ignore("Currently ignored because of a BUG")
public void testURI_17_EntityMediaResourceDollarValue() throws Exception {
// create test set
- FitTestSet testSet = FitTestSet.create(UriType.URI17, "/Employees('1')/$value").expectedStatusCode(HttpStatusCodes.OK).expectedContentType("image/jpeg").init();
+ FitTestSet testSet =
+ FitTestSet.create(UriType.URI17, "/Employees('1')/$value").expectedStatusCode(HttpStatusCodes.OK)
+ .expectedContentType("image/jpeg").init();
// every combination of $format and $value is a 'BAD REQUEST'
- testSet.setTestParam(Arrays.asList("?$format=json", "?$format=xml", "?$format=atom"), ACCEPT_HEADER_VALUES, HttpStatusCodes.BAD_REQUEST, "application/xml");
+ testSet.setTestParam(Arrays.asList("?$format=json", "?$format=xml", "?$format=atom"), ACCEPT_HEADER_VALUES,
+ HttpStatusCodes.BAD_REQUEST, "application/xml");
//
final List<String> jsonAcceptHeaders = Arrays.asList(
"application/json",
"application/json; charset=utf-8"
);
// TODO: check which behavior is currently wanted
- testSet.setTestParam(Arrays.asList("?$format=json", "?$format=xml", "?$format=atom"), jsonAcceptHeaders, HttpStatusCodes.BAD_REQUEST, "application/json");
+ testSet.setTestParam(Arrays.asList("?$format=json", "?$format=xml", "?$format=atom"), jsonAcceptHeaders,
+ HttpStatusCodes.BAD_REQUEST, "application/json");
testSet.execute(getEndpoint());
}
@@ -403,14 +443,16 @@ public class ContentNegotiationGetRequestTest extends AbstractContentNegotiation
.expectedStatusCode(HttpStatusCodes.OK).expectedContentType("text/plain; charset=utf-8").init();
// every combination of $format and $value is a 'BAD REQUEST'
- testSet.setTestParam(Arrays.asList("?$format=json", "?$format=xml", "?$format=atom"), ACCEPT_HEADER_VALUES, HttpStatusCodes.BAD_REQUEST, "application/xml");
+ testSet.setTestParam(Arrays.asList("?$format=json", "?$format=xml", "?$format=atom"), ACCEPT_HEADER_VALUES,
+ HttpStatusCodes.BAD_REQUEST, "application/xml");
//
final List<String> jsonAcceptHeaders = Arrays.asList(
"application/json",
"application/json; charset=utf-8"
);
// TODO: check which behavior is currently wanted
- testSet.setTestParam(Arrays.asList("?$format=json", "?$format=xml", "?$format=atom"), jsonAcceptHeaders, HttpStatusCodes.BAD_REQUEST, "application/json");
+ testSet.setTestParam(Arrays.asList("?$format=json", "?$format=xml", "?$format=atom"), jsonAcceptHeaders,
+ HttpStatusCodes.BAD_REQUEST, "application/json");
testSet.execute(getEndpoint());
}