You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by il...@apache.org on 2014/04/23 13:26:42 UTC
git commit: [OLINGO-234] OperationImportInvokeTestITCase moved to fit]
Repository: olingo-odata4
Updated Branches:
refs/heads/master 32fcb8cb5 -> f87321f98
[OLINGO-234] OperationImportInvokeTestITCase moved to fit]
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/f87321f9
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/f87321f9
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/f87321f9
Branch: refs/heads/master
Commit: f87321f98ed1df8bb314756f5a2540e30849d81d
Parents: 32fcb8c
Author: Francesco Chicchiriccò <il...@apache.org>
Authored: Wed Apr 23 13:26:32 2014 +0200
Committer: Francesco Chicchiriccò <il...@apache.org>
Committed: Wed Apr 23 13:26:32 2014 +0200
----------------------------------------------------------------------
.../org/apache/olingo/fit/AbstractServices.java | 24 +-
.../java/org/apache/olingo/fit/V4Services.java | 335 ++++++++++++++++++-
.../fit/serializer/JsonPropertyContainer.java | 35 ++
.../main/resources/V40/Products/feed.full.json | 139 ++++++++
fit/src/main/resources/V40/Products/feed.xml | 167 +++++++++
.../invoke/AbstractODataInvokeRequest.java | 2 +-
.../invoke/v3/ODataInvokeRequestImpl.java | 4 +-
.../invoke/v4/ODataInvokeRequestImpl.java | 4 +-
.../client/core/it/v4/BatchTestITCase.java | 2 +-
.../it/v4/OperationImportInvokeTestITCase.java | 75 +----
.../core/data/AbstractJsonSerializer.java | 2 +-
.../commons/core/data/AtomSerializer.java | 6 +-
.../commons/core/data/JSONEntrySerializer.java | 16 +-
.../core/data/JSONPropertySerializer.java | 13 +
14 files changed, 730 insertions(+), 94 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f87321f9/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java b/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java
index 2ed2053..03c59e4 100644
--- a/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java
+++ b/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java
@@ -419,7 +419,7 @@ public abstract class AbstractServices {
} else {
final Container<JSONEntryImpl> jcont =
mapper.readValue(IOUtils.toInputStream(changes), new TypeReference<JSONEntryImpl>() {
- });
+ });
entryChanges = dataBinder.getAtomEntry(jcont.getObject());
}
@@ -609,7 +609,7 @@ public abstract class AbstractServices {
} else {
final Container<JSONEntryImpl> jcontainer =
mapper.readValue(IOUtils.toInputStream(entity), new TypeReference<JSONEntryImpl>() {
- });
+ });
entry = dataBinder.getAtomEntry(jcontainer.getObject());
@@ -636,7 +636,7 @@ public abstract class AbstractServices {
Container<AtomEntryImpl> result = atomDeserializer.read(serialization, AtomEntryImpl.class);
result = new Container<AtomEntryImpl>(
URI.create(Constants.get(version, ConstantKey.DEFAULT_SERVICE_URL)
- + "$metadata#" + entitySetName + "/$entity"), null, result.getObject());
+ + "$metadata#" + entitySetName + "/$entity"), null, result.getObject());
final String path = Commons.getEntityBasePath(entitySetName, entityKey);
FSManager.instance(version).putInMemory(
@@ -698,13 +698,13 @@ public abstract class AbstractServices {
replaceAll("\"Salary\":[0-9]*,", "\"Salary\":0,").
replaceAll("\"Title\":\".*\"", "\"Title\":\"[Sacked]\"").
replaceAll("\\<d:Salary m:type=\"Edm.Int32\"\\>.*\\</d:Salary\\>",
- "<d:Salary m:type=\"Edm.Int32\">0</d:Salary>").
+ "<d:Salary m:type=\"Edm.Int32\">0</d:Salary>").
replaceAll("\\<d:Title\\>.*\\</d:Title\\>", "<d:Title>[Sacked]</d:Title>");
final FSManager fsManager = FSManager.instance(version);
fsManager.putInMemory(IOUtils.toInputStream(newContent, "UTF-8"),
fsManager.getAbsolutePath(Commons.getEntityBasePath("Person", entityId) + Constants.get(version,
- ConstantKey.ENTITY), utils.getKey()));
+ ConstantKey.ENTITY), utils.getKey()));
return utils.getValue().createResponse(null, null, null, utils.getKey(), Response.Status.NO_CONTENT);
} catch (Exception e) {
@@ -756,9 +756,9 @@ public abstract class AbstractServices {
final Long newSalary = Long.valueOf(salaryMatcher.group(1)) + n;
newContent = newContent.
replaceAll("\"Salary\":" + salaryMatcher.group(1) + ",",
- "\"Salary\":" + newSalary + ",").
+ "\"Salary\":" + newSalary + ",").
replaceAll("\\<d:Salary m:type=\"Edm.Int32\"\\>" + salaryMatcher.group(1) + "</d:Salary\\>",
- "<d:Salary m:type=\"Edm.Int32\">" + newSalary + "</d:Salary>");
+ "<d:Salary m:type=\"Edm.Int32\">" + newSalary + "</d:Salary>");
}
FSManager.instance(version).putInMemory(IOUtils.toInputStream(newContent, "UTF-8"),
@@ -888,7 +888,7 @@ public abstract class AbstractServices {
} else {
mapper.writeValue(
writer, new JsonFeedContainer<JSONFeedImpl>(container.getContextURL(), container.getMetadataETag(),
- dataBinder.getJsonFeed(container.getObject())));
+ dataBinder.getJsonFeed(container.getObject())));
}
return xml.createResponse(
@@ -1503,8 +1503,8 @@ public abstract class AbstractServices {
mapper.writeValue(
writer,
new JsonFeedContainer<JSONFeedImpl>(container.getContextURL(),
- container.getMetadataETag(),
- dataBinder.getJsonFeed((AtomFeedImpl) container.getObject())));
+ container.getMetadataETag(),
+ dataBinder.getJsonFeed((AtomFeedImpl) container.getObject())));
}
} else {
final Container<Entry> container = atomDeserializer.<Entry, AtomEntryImpl>read(stream, AtomEntryImpl.class);
@@ -1516,8 +1516,8 @@ public abstract class AbstractServices {
mapper.writeValue(
writer,
new JsonEntryContainer<JSONEntryImpl>(container.getContextURL(),
- container.getMetadataETag(),
- dataBinder.getJsonEntry((AtomEntryImpl) container.getObject())));
+ container.getMetadataETag(),
+ dataBinder.getJsonEntry((AtomEntryImpl) container.getObject())));
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f87321f9/fit/src/main/java/org/apache/olingo/fit/V4Services.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/V4Services.java b/fit/src/main/java/org/apache/olingo/fit/V4Services.java
index 290e821..9165af1 100644
--- a/fit/src/main/java/org/apache/olingo/fit/V4Services.java
+++ b/fit/src/main/java/org/apache/olingo/fit/V4Services.java
@@ -25,6 +25,8 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
+import java.io.StringWriter;
+import java.net.URI;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -48,17 +50,25 @@ import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.cxf.interceptor.InInterceptors;
import org.apache.cxf.jaxrs.ext.multipart.Attachment;
+import org.apache.olingo.commons.api.data.CollectionValue;
import org.apache.olingo.commons.api.data.Container;
+import org.apache.olingo.commons.api.data.Entry;
import org.apache.olingo.commons.api.data.Feed;
import org.apache.olingo.commons.api.data.Property;
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
import org.apache.olingo.commons.core.data.AtomEntryImpl;
import org.apache.olingo.commons.core.data.AtomFeedImpl;
+import org.apache.olingo.commons.core.data.AtomPropertyImpl;
+import org.apache.olingo.commons.core.data.CollectionValueImpl;
+import org.apache.olingo.commons.core.data.EnumValueImpl;
import org.apache.olingo.commons.core.data.JSONEntryImpl;
import org.apache.olingo.commons.core.data.JSONFeedImpl;
+import org.apache.olingo.commons.core.data.JSONPropertyImpl;
+import org.apache.olingo.commons.core.data.PrimitiveValueImpl;
import org.apache.olingo.commons.core.edm.EdmTypeInfo;
import org.apache.olingo.fit.methods.PATCH;
import org.apache.olingo.fit.serializer.JsonFeedContainer;
+import org.apache.olingo.fit.serializer.JsonPropertyContainer;
import org.apache.olingo.fit.utils.AbstractUtilities;
import org.apache.olingo.fit.utils.Accept;
import org.apache.olingo.fit.utils.ConstantKey;
@@ -196,7 +206,7 @@ public class V4Services extends AbstractServices {
return utils.getValue().createResponse(
FSManager.instance(version).readFile(Constants.get(version, ConstantKey.REF)
- + File.separatorChar + filename, utils.getKey()),
+ + File.separatorChar + filename, utils.getKey()),
null,
utils.getKey());
} catch (Exception e) {
@@ -218,7 +228,7 @@ public class V4Services extends AbstractServices {
final Response response =
getEntityInternal(uriInfo.getRequestUri().toASCIIString(),
- accept, entitySetName, entityId, accept, StringUtils.EMPTY, StringUtils.EMPTY, false);
+ accept, entitySetName, entityId, accept, StringUtils.EMPTY, StringUtils.EMPTY, false);
return response.getStatus() >= 400
? postNewEntity(uriInfo, accept, contentType, prefer, entitySetName, changes)
: super.patchEntity(uriInfo, accept, contentType, prefer, ifMatch, entitySetName, entityId, changes);
@@ -272,7 +282,7 @@ public class V4Services extends AbstractServices {
final InputStream entry = FSManager.instance(version).
readFile(containedPath(entityId, containedEntitySetName).
- append('(').append(containedEntityId).append(')').toString(), Accept.ATOM);
+ append('(').append(containedEntityId).append(')').toString(), Accept.ATOM);
final Container<AtomEntryImpl> container = atomDeserializer.read(entry, AtomEntryImpl.class);
@@ -315,7 +325,7 @@ public class V4Services extends AbstractServices {
} else {
final Container<JSONEntryImpl> jcontainer =
mapper.readValue(IOUtils.toInputStream(entity), new TypeReference<JSONEntryImpl>() {
- });
+ });
entry = dataBinder.getAtomEntry(jcontainer.getObject());
@@ -413,7 +423,7 @@ public class V4Services extends AbstractServices {
final Container<JSONEntryImpl> jsonContainer = mapper.readValue(IOUtils.toInputStream(changes),
new TypeReference<JSONEntryImpl>() {
- });
+ });
jsonContainer.getObject().setType(typeInfo.getFullQualifiedName().toString());
entryChanges = dataBinder.getAtomEntry(jsonContainer.getObject());
}
@@ -446,7 +456,7 @@ public class V4Services extends AbstractServices {
// 1. Fetch the contained entity to be removed
final InputStream entry = FSManager.instance(version).
readFile(containedPath(entityId, containedEntitySetName).
- append('(').append(containedEntityId).append(')').toString(), Accept.ATOM);
+ append('(').append(containedEntityId).append(')').toString(), Accept.ATOM);
final Container<AtomEntryImpl> container = atomDeserializer.read(entry, AtomEntryImpl.class);
// 2. Remove the contained entity
@@ -510,7 +520,7 @@ public class V4Services extends AbstractServices {
} else {
mapper.writeValue(
writer, new JsonFeedContainer<JSONFeedImpl>(container.getContextURL(), container.getMetadataETag(),
- dataBinder.getJsonFeed(container.getObject())));
+ dataBinder.getJsonFeed(container.getObject())));
}
return xml.createResponse(
@@ -522,4 +532,315 @@ public class V4Services extends AbstractServices {
return xml.createFaultResponse(accept, e);
}
}
+
+ @GET
+ @Path("/GetDefaultColor()")
+ public Response functionGetDefaultColor(
+ @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
+ @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format) {
+
+ try {
+ final Accept acceptType;
+ if (StringUtils.isNotBlank(format)) {
+ acceptType = Accept.valueOf(format.toUpperCase());
+ } else {
+ acceptType = Accept.parse(accept, version);
+ }
+
+ final AtomPropertyImpl property = new AtomPropertyImpl();
+ property.setType("Microsoft.Test.OData.Services.ODataWCFService.Color");
+ property.setValue(new EnumValueImpl("Red"));
+ final Container<AtomPropertyImpl> container = new Container<AtomPropertyImpl>(
+ URI.create(Constants.get(version, ConstantKey.ODATA_METADATA_PREFIX) + property.getType()), null,
+ property);
+
+ final ByteArrayOutputStream content = new ByteArrayOutputStream();
+ final OutputStreamWriter writer = new OutputStreamWriter(content, Constants.ENCODING);
+
+ if (acceptType == Accept.XML) {
+ atomSerializer.write(writer, container);
+ writer.flush();
+ writer.close();
+ } else {
+ mapper.writeValue(
+ writer, new JsonPropertyContainer<JSONPropertyImpl>(container.getContextURL(),
+ container.getMetadataETag(), dataBinder.getJsonProperty(container.getObject())));
+ }
+
+ return xml.createResponse(
+ null,
+ new ByteArrayInputStream(content.toByteArray()),
+ null,
+ acceptType);
+ } catch (Exception e) {
+ return xml.createFaultResponse(accept, e);
+ }
+ }
+
+ @GET
+ @Path("/GetPerson2({param:.*})")
+ public Response functionGetPerson2(
+ @Context UriInfo uriInfo,
+ @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
+ @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format) {
+
+ return getEntityInternal(
+ uriInfo.getRequestUri().toASCIIString(), accept, "Customers", "1", format, null, null, false);
+ }
+
+ @GET
+ @Path("/GetPerson({param:.*})")
+ public Response functionGetPerson(
+ @Context UriInfo uriInfo,
+ @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
+ @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format) {
+
+ return getEntityInternal(
+ uriInfo.getRequestUri().toASCIIString(), accept, "Customers", "1", format, null, null, false);
+ }
+
+ @GET
+ @Path("/GetAllProducts()")
+ public Response functionGetAllProducts(
+ @Context UriInfo uriInfo,
+ @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
+ @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format) {
+
+ return getEntitySet(uriInfo, accept, "Products", format, null, null, null, null);
+ }
+
+ @GET
+ @Path("/GetProductsByAccessLevel({param:.*})")
+ public Response functionGetProductsByAccessLevel(
+ @Context UriInfo uriInfo,
+ @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
+ @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format) {
+
+ try {
+ final Accept acceptType;
+ if (StringUtils.isNotBlank(format)) {
+ acceptType = Accept.valueOf(format.toUpperCase());
+ } else {
+ acceptType = Accept.parse(accept, version);
+ }
+
+ final AtomPropertyImpl property = new AtomPropertyImpl();
+ property.setType("Collection(String)");
+ final CollectionValue value = new CollectionValueImpl();
+ value.get().add(new PrimitiveValueImpl("Cheetos"));
+ value.get().add(new PrimitiveValueImpl("Mushrooms"));
+ value.get().add(new PrimitiveValueImpl("Apple"));
+ value.get().add(new PrimitiveValueImpl("Car"));
+ value.get().add(new PrimitiveValueImpl("Computer"));
+ property.setValue(value);
+ final Container<AtomPropertyImpl> container = new Container<AtomPropertyImpl>(
+ URI.create(Constants.get(version, ConstantKey.ODATA_METADATA_PREFIX) + property.getType()), null,
+ property);
+
+ final ByteArrayOutputStream content = new ByteArrayOutputStream();
+ final OutputStreamWriter writer = new OutputStreamWriter(content, Constants.ENCODING);
+
+ if (acceptType == Accept.XML) {
+ atomSerializer.write(writer, container);
+ writer.flush();
+ writer.close();
+ } else {
+ mapper.writeValue(
+ writer, new JsonPropertyContainer<JSONPropertyImpl>(container.getContextURL(),
+ container.getMetadataETag(), dataBinder.getJsonProperty(container.getObject())));
+ }
+
+ return xml.createResponse(
+ null,
+ new ByteArrayInputStream(content.toByteArray()),
+ null,
+ acceptType);
+ } catch (Exception e) {
+ return xml.createFaultResponse(accept, e);
+ }
+ }
+
+ @GET
+ @Path("/GetBossEmails({param:.*})")
+ public Response functionGetBossEmails(
+ @Context UriInfo uriInfo,
+ @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
+ @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format) {
+
+ try {
+ final Accept acceptType;
+ if (StringUtils.isNotBlank(format)) {
+ acceptType = Accept.valueOf(format.toUpperCase());
+ } else {
+ acceptType = Accept.parse(accept, version);
+ }
+
+ final AtomPropertyImpl property = new AtomPropertyImpl();
+ property.setType("Collection(Edm.String)");
+ final CollectionValue value = new CollectionValueImpl();
+ value.get().add(new PrimitiveValueImpl("first@olingo.apache.org"));
+ value.get().add(new PrimitiveValueImpl("second@olingo.apache.org"));
+ property.setValue(value);
+ final Container<AtomPropertyImpl> container = new Container<AtomPropertyImpl>(
+ URI.create(Constants.get(version, ConstantKey.ODATA_METADATA_PREFIX) + property.getType()), null,
+ property);
+
+ final ByteArrayOutputStream content = new ByteArrayOutputStream();
+ final OutputStreamWriter writer = new OutputStreamWriter(content, Constants.ENCODING);
+
+ if (acceptType == Accept.XML) {
+ atomSerializer.write(writer, container);
+ writer.flush();
+ writer.close();
+ } else {
+ mapper.writeValue(
+ writer, new JsonPropertyContainer<JSONPropertyImpl>(container.getContextURL(),
+ container.getMetadataETag(), dataBinder.getJsonProperty(container.getObject())));
+ }
+
+ return xml.createResponse(
+ null,
+ new ByteArrayInputStream(content.toByteArray()),
+ null,
+ acceptType);
+ } catch (Exception e) {
+ return xml.createFaultResponse(accept, e);
+ }
+ }
+
+ @POST
+ @Path("/Discount()")
+ public Response actionDiscount(
+ @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
+ @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) String contentType,
+ @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format,
+ final String param) {
+
+ try {
+ final Accept acceptType;
+ if (StringUtils.isNotBlank(format)) {
+ acceptType = Accept.valueOf(format.toUpperCase());
+ } else {
+ acceptType = Accept.parse(accept, version);
+ }
+
+ final Accept contentTypeValue = Accept.parse(contentType, version);
+ Property property;
+ if (contentTypeValue == Accept.ATOM) {
+ final Container<AtomPropertyImpl> paramContainer = atomDeserializer.read(
+ IOUtils.toInputStream(param, Constants.ENCODING), AtomPropertyImpl.class);
+ property = paramContainer.getObject();
+ } else {
+ final Container<JSONPropertyImpl> paramContainer =
+ mapper.readValue(IOUtils.toInputStream(param, Constants.ENCODING),
+ new TypeReference<JSONPropertyImpl>() {
+ });
+ property = paramContainer.getObject();
+ }
+
+ assert property.getValue().isComplex();
+ assert 1 == property.getValue().asComplex().get().size();
+ assert "Edm.Int32".equals(property.getValue().asComplex().get().get(0).getType());
+ assert property.getValue().asComplex().get().get(0).getValue().isPrimitive();
+ assert "percentage".equals(property.getValue().asComplex().get().get(0).getName());
+
+ return xml.createResponse(null, null, null, acceptType, Response.Status.NO_CONTENT);
+ } catch (Exception e) {
+ return xml.createFaultResponse(accept, e);
+ }
+ }
+
+ @POST
+ @Path("/ResetBossAddress()")
+ public Response actionResetBossAddress(
+ @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
+ @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) String contentType,
+ @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format,
+ final String param) {
+
+ try {
+ final Accept acceptType;
+ if (StringUtils.isNotBlank(format)) {
+ acceptType = Accept.valueOf(format.toUpperCase());
+ } else {
+ acceptType = Accept.parse(accept, version);
+ }
+
+ final Accept contentTypeValue = Accept.parse(contentType, version);
+ Property property;
+ if (contentTypeValue == Accept.XML) {
+ final Container<AtomPropertyImpl> paramContainer = atomDeserializer.read(
+ IOUtils.toInputStream(param, Constants.ENCODING), AtomPropertyImpl.class);
+ property = paramContainer.getObject();
+ } else {
+ final Container<JSONPropertyImpl> paramContainer =
+ mapper.readValue(IOUtils.toInputStream(param, Constants.ENCODING),
+ new TypeReference<JSONPropertyImpl>() {
+ });
+ property = paramContainer.getObject();
+ }
+
+ assert "Microsoft.Test.OData.Services.ODataWCFService.Address".equals(property.getType());
+ assert property.getValue().isComplex();
+
+ return xml.createResponse(
+ null,
+ new ByteArrayInputStream(param.getBytes(Constants.ENCODING)),
+ null,
+ acceptType);
+ } catch (Exception e) {
+ return xml.createFaultResponse(accept, e);
+ }
+ }
+
+ @POST
+ @Path("/ResetBossEmail()")
+ public Response actionResetBossEmail(
+ @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
+ @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) String contentType,
+ @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format,
+ final String param) {
+
+ try {
+ final Accept acceptType;
+ if (StringUtils.isNotBlank(format)) {
+ acceptType = Accept.valueOf(format.toUpperCase());
+ } else {
+ acceptType = Accept.parse(accept, version);
+ }
+
+ final Accept contentTypeValue = Accept.parse(contentType, version);
+ Entry entry;
+ if (contentTypeValue == Accept.XML) {
+ final Container<AtomEntryImpl> paramContainer = atomDeserializer.read(
+ IOUtils.toInputStream(param, Constants.ENCODING), AtomEntryImpl.class);
+ entry = paramContainer.getObject();
+ } else {
+ final Container<JSONEntryImpl> paramContainer =
+ mapper.readValue(IOUtils.toInputStream(param, Constants.ENCODING),
+ new TypeReference<JSONEntryImpl>() {
+ });
+ entry = paramContainer.getObject();
+ }
+
+ assert 1 == entry.getProperties().size();
+ assert "Collection(Edm.String)".equals(entry.getProperty("emails").getType());
+ assert entry.getProperty("emails").getValue().isCollection();
+
+ final StringWriter writer = new StringWriter();
+ if (acceptType == Accept.XML) {
+ atomSerializer.write(writer, entry.getProperty("emails"));
+ } else {
+ mapper.writeValue(writer, entry.getProperty("emails"));
+ }
+
+ return xml.createResponse(
+ null,
+ new ByteArrayInputStream(writer.toString().getBytes(Constants.ENCODING)),
+ null,
+ acceptType);
+ } catch (Exception e) {
+ return xml.createFaultResponse(accept, e);
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f87321f9/fit/src/main/java/org/apache/olingo/fit/serializer/JsonPropertyContainer.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/serializer/JsonPropertyContainer.java b/fit/src/main/java/org/apache/olingo/fit/serializer/JsonPropertyContainer.java
new file mode 100644
index 0000000..a79c397
--- /dev/null
+++ b/fit/src/main/java/org/apache/olingo/fit/serializer/JsonPropertyContainer.java
@@ -0,0 +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
+ *
+ * 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.
+ */
+package org.apache.olingo.fit.serializer;
+
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import java.net.URI;
+import org.apache.olingo.commons.api.data.Container;
+import org.apache.olingo.commons.core.data.JSONPropertyDeserializer;
+import org.apache.olingo.commons.core.data.JSONPropertySerializer;
+
+@JsonDeserialize(using = JSONPropertyDeserializer.class)
+@JsonSerialize(using = JSONPropertySerializer.class)
+public class JsonPropertyContainer<T> extends Container<T> {
+
+ public JsonPropertyContainer(final URI contextURL, final String metadataETag, final T object) {
+ super(contextURL, metadataETag, object);
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f87321f9/fit/src/main/resources/V40/Products/feed.full.json
----------------------------------------------------------------------
diff --git a/fit/src/main/resources/V40/Products/feed.full.json b/fit/src/main/resources/V40/Products/feed.full.json
new file mode 100644
index 0000000..e35071a
--- /dev/null
+++ b/fit/src/main/resources/V40/Products/feed.full.json
@@ -0,0 +1,139 @@
+{
+ "@odata.context": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/$metadata#Products",
+ "value": [{
+ "@odata.type": "#Microsoft.Test.OData.Services.ODataWCFService.Product",
+ "@odata.id": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Products(5)",
+ "@odata.editLink": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Products(5)",
+ "ProductID": 5,
+ "Name": "Cheetos",
+ "QuantityPerUnit": "100g Bag",
+ "UnitPrice@odata.type": "#Single",
+ "UnitPrice": 3.24,
+ "QuantityInStock": 100,
+ "Discontinued": true,
+ "UserAccess@odata.type": "#Microsoft.Test.OData.Services.ODataWCFService.AccessLevel",
+ "UserAccess": "None",
+ "SkinColor@odata.type": "#Microsoft.Test.OData.Services.ODataWCFService.Color",
+ "SkinColor": "Red",
+ "CoverColors@odata.type": "#Collection(Microsoft.Test.OData.Services.ODataWCFService.Color)",
+ "CoverColors": ["Green", "Blue", "Blue"],
+ "Details@odata.associationLink": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Products(5)/Details/$ref",
+ "Details@odata.navigationLink": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Products(5)/Details",
+ "#Microsoft.Test.OData.Services.ODataWCFService.AddAccessRight": {
+ "title": "Microsoft.Test.OData.Services.ODataWCFService.AddAccessRight",
+ "target": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Products(5)/Microsoft.Test.OData.Services.ODataWCFService.AddAccessRight"
+ },
+ "#Microsoft.Test.OData.Services.ODataWCFService.GetProductDetails": {
+ "title": "Microsoft.Test.OData.Services.ODataWCFService.GetProductDetails",
+ "target": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Products(5)/Microsoft.Test.OData.Services.ODataWCFService.GetProductDetails"
+ }
+ }, {
+ "@odata.type": "#Microsoft.Test.OData.Services.ODataWCFService.Product",
+ "@odata.id": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Products(6)",
+ "@odata.editLink": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Products(6)",
+ "ProductID": 6,
+ "Name": "Mushrooms",
+ "QuantityPerUnit": "Pound",
+ "UnitPrice@odata.type": "#Single",
+ "UnitPrice": 3.24,
+ "QuantityInStock": 100,
+ "Discontinued": false,
+ "UserAccess@odata.type": "#Microsoft.Test.OData.Services.ODataWCFService.AccessLevel",
+ "UserAccess": "ReadWrite",
+ "SkinColor@odata.type": "#Microsoft.Test.OData.Services.ODataWCFService.Color",
+ "SkinColor": "Blue",
+ "CoverColors@odata.type": "#Collection(Microsoft.Test.OData.Services.ODataWCFService.Color)",
+ "CoverColors": ["Red", "Blue"],
+ "Details@odata.associationLink": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Products(6)/Details/$ref",
+ "Details@odata.navigationLink": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Products(6)/Details",
+ "#Microsoft.Test.OData.Services.ODataWCFService.AddAccessRight": {
+ "title": "Microsoft.Test.OData.Services.ODataWCFService.AddAccessRight",
+ "target": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Products(6)/Microsoft.Test.OData.Services.ODataWCFService.AddAccessRight"
+ },
+ "#Microsoft.Test.OData.Services.ODataWCFService.GetProductDetails": {
+ "title": "Microsoft.Test.OData.Services.ODataWCFService.GetProductDetails",
+ "target": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Products(6)/Microsoft.Test.OData.Services.ODataWCFService.GetProductDetails"
+ }
+ }, {
+ "@odata.type": "#Microsoft.Test.OData.Services.ODataWCFService.Product",
+ "@odata.id": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Products(7)",
+ "@odata.editLink": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Products(7)",
+ "ProductID": 7,
+ "Name": "Apple",
+ "QuantityPerUnit": "Pound",
+ "UnitPrice@odata.type": "#Single",
+ "UnitPrice": 0.35,
+ "QuantityInStock": 20,
+ "Discontinued": false,
+ "UserAccess@odata.type": "#Microsoft.Test.OData.Services.ODataWCFService.AccessLevel",
+ "UserAccess": "Read",
+ "SkinColor@odata.type": "#Microsoft.Test.OData.Services.ODataWCFService.Color",
+ "SkinColor": "Red",
+ "CoverColors@odata.type": "#Collection(Microsoft.Test.OData.Services.ODataWCFService.Color)",
+ "CoverColors": ["Blue"],
+ "Details@odata.associationLink": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Products(7)/Details/$ref",
+ "Details@odata.navigationLink": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Products(7)/Details",
+ "#Microsoft.Test.OData.Services.ODataWCFService.AddAccessRight": {
+ "title": "Microsoft.Test.OData.Services.ODataWCFService.AddAccessRight",
+ "target": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Products(7)/Microsoft.Test.OData.Services.ODataWCFService.AddAccessRight"
+ },
+ "#Microsoft.Test.OData.Services.ODataWCFService.GetProductDetails": {
+ "title": "Microsoft.Test.OData.Services.ODataWCFService.GetProductDetails",
+ "target": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Products(7)/Microsoft.Test.OData.Services.ODataWCFService.GetProductDetails"
+ }
+ }, {
+ "@odata.type": "#Microsoft.Test.OData.Services.ODataWCFService.Product",
+ "@odata.id": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Products(8)",
+ "@odata.editLink": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Products(8)",
+ "ProductID": 8,
+ "Name": "Car",
+ "QuantityPerUnit": "Pound",
+ "UnitPrice@odata.type": "#Single",
+ "UnitPrice": 28000,
+ "QuantityInStock": 300,
+ "Discontinued": false,
+ "UserAccess@odata.type": "#Microsoft.Test.OData.Services.ODataWCFService.AccessLevel",
+ "UserAccess": "Execute",
+ "SkinColor@odata.type": "#Microsoft.Test.OData.Services.ODataWCFService.Color",
+ "SkinColor": "Red",
+ "CoverColors@odata.type": "#Collection(Microsoft.Test.OData.Services.ODataWCFService.Color)",
+ "CoverColors": ["Red", "Red", "Blue"],
+ "Details@odata.associationLink": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Products(8)/Details/$ref",
+ "Details@odata.navigationLink": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Products(8)/Details",
+ "#Microsoft.Test.OData.Services.ODataWCFService.AddAccessRight": {
+ "title": "Microsoft.Test.OData.Services.ODataWCFService.AddAccessRight",
+ "target": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Products(8)/Microsoft.Test.OData.Services.ODataWCFService.AddAccessRight"
+ },
+ "#Microsoft.Test.OData.Services.ODataWCFService.GetProductDetails": {
+ "title": "Microsoft.Test.OData.Services.ODataWCFService.GetProductDetails",
+ "target": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Products(8)/Microsoft.Test.OData.Services.ODataWCFService.GetProductDetails"
+ }
+ }, {
+ "@odata.type": "#Microsoft.Test.OData.Services.ODataWCFService.Product",
+ "@odata.id": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Products(9)",
+ "@odata.editLink": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Products(9)",
+ "ProductID": 9,
+ "Name": "Computer",
+ "QuantityPerUnit": "Pound",
+ "UnitPrice@odata.type": "#Single",
+ "UnitPrice": 1250,
+ "QuantityInStock": 1000,
+ "Discontinued": false,
+ "UserAccess@odata.type": "#Microsoft.Test.OData.Services.ODataWCFService.AccessLevel",
+ "UserAccess": "Read",
+ "SkinColor@odata.type": "#Microsoft.Test.OData.Services.ODataWCFService.Color",
+ "SkinColor": "Green",
+ "CoverColors@odata.type": "#Collection(Microsoft.Test.OData.Services.ODataWCFService.Color)",
+ "CoverColors": ["Green"],
+ "Details@odata.associationLink": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Products(9)/Details/$ref",
+ "Details@odata.navigationLink": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Products(9)/Details",
+ "#Microsoft.Test.OData.Services.ODataWCFService.AddAccessRight": {
+ "title": "Microsoft.Test.OData.Services.ODataWCFService.AddAccessRight",
+ "target": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Products(9)/Microsoft.Test.OData.Services.ODataWCFService.AddAccessRight"
+ },
+ "#Microsoft.Test.OData.Services.ODataWCFService.GetProductDetails": {
+ "title": "Microsoft.Test.OData.Services.ODataWCFService.GetProductDetails",
+ "target": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Products(9)/Microsoft.Test.OData.Services.ODataWCFService.GetProductDetails"
+ }
+ }]
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f87321f9/fit/src/main/resources/V40/Products/feed.xml
----------------------------------------------------------------------
diff --git a/fit/src/main/resources/V40/Products/feed.xml b/fit/src/main/resources/V40/Products/feed.xml
new file mode 100644
index 0000000..7f5113e
--- /dev/null
+++ b/fit/src/main/resources/V40/Products/feed.xml
@@ -0,0 +1,167 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+
+ 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
+
+ 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.
+
+-->
+<feed xml:base="http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/"
+ xmlns="http://www.w3.org/2005/Atom"
+ xmlns:d="http://docs.oasis-open.org/odata/ns/data"
+ xmlns:m="http://docs.oasis-open.org/odata/ns/metadata"
+ xmlns:georss="http://www.georss.org/georss"
+ xmlns:gml="http://www.opengis.net/gml"
+ m:context="http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/$metadata#Products">
+ <id>http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Products</id>
+ <title />
+ <updated>2014-04-23T08:04:46Z</updated>
+ <entry>
+ <id>http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Products(5)</id>
+ <category term="#Microsoft.Test.OData.Services.ODataWCFService.Product" scheme="http://docs.oasis-open.org/odata/ns/scheme" />
+ <link rel="edit" href="http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Products(5)" />
+ <link rel="http://docs.oasis-open.org/odata/ns/related/Details" type="application/atom+xml;type=feed" title="Details" href="http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Products(5)/Details" />
+ <title />
+ <updated>2014-04-23T08:04:46Z</updated>
+ <author>
+ <name />
+ </author>
+ <content type="application/xml">
+ <m:properties>
+ <d:ProductID m:type="Int32">5</d:ProductID>
+ <d:Name>Cheetos</d:Name>
+ <d:QuantityPerUnit>100g Bag</d:QuantityPerUnit>
+ <d:UnitPrice m:type="Single">3.24</d:UnitPrice>
+ <d:QuantityInStock m:type="Int32">100</d:QuantityInStock>
+ <d:Discontinued m:type="Boolean">true</d:Discontinued>
+ <d:UserAccess m:type="#Microsoft.Test.OData.Services.ODataWCFService.AccessLevel">None</d:UserAccess>
+ <d:SkinColor m:type="#Microsoft.Test.OData.Services.ODataWCFService.Color">Red</d:SkinColor>
+ <d:CoverColors m:type="#Collection(Microsoft.Test.OData.Services.ODataWCFService.Color)">
+ <m:element>Green</m:element>
+ <m:element>Blue</m:element>
+ <m:element>Blue</m:element>
+ </d:CoverColors>
+ </m:properties>
+ </content>
+ </entry>
+ <entry>
+ <id>http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Products(6)</id>
+ <category term="#Microsoft.Test.OData.Services.ODataWCFService.Product" scheme="http://docs.oasis-open.org/odata/ns/scheme" />
+ <link rel="edit" href="http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Products(6)" />
+ <link rel="http://docs.oasis-open.org/odata/ns/related/Details" type="application/atom+xml;type=feed" title="Details" href="http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Products(6)/Details" />
+ <title />
+ <updated>2014-04-23T08:04:46Z</updated>
+ <author>
+ <name />
+ </author>
+ <content type="application/xml">
+ <m:properties>
+ <d:ProductID m:type="Int32">6</d:ProductID>
+ <d:Name>Mushrooms</d:Name>
+ <d:QuantityPerUnit>Pound</d:QuantityPerUnit>
+ <d:UnitPrice m:type="Single">3.24</d:UnitPrice>
+ <d:QuantityInStock m:type="Int32">100</d:QuantityInStock>
+ <d:Discontinued m:type="Boolean">false</d:Discontinued>
+ <d:UserAccess m:type="#Microsoft.Test.OData.Services.ODataWCFService.AccessLevel">ReadWrite</d:UserAccess>
+ <d:SkinColor m:type="#Microsoft.Test.OData.Services.ODataWCFService.Color">Blue</d:SkinColor>
+ <d:CoverColors m:type="#Collection(Microsoft.Test.OData.Services.ODataWCFService.Color)">
+ <m:element>Red</m:element>
+ <m:element>Blue</m:element>
+ </d:CoverColors>
+ </m:properties>
+ </content>
+ </entry>
+ <entry>
+ <id>http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Products(7)</id>
+ <category term="#Microsoft.Test.OData.Services.ODataWCFService.Product" scheme="http://docs.oasis-open.org/odata/ns/scheme" />
+ <link rel="edit" href="http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Products(7)" />
+ <link rel="http://docs.oasis-open.org/odata/ns/related/Details" type="application/atom+xml;type=feed" title="Details" href="http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Products(7)/Details" />
+ <title />
+ <updated>2014-04-23T08:04:46Z</updated>
+ <author>
+ <name />
+ </author>
+ <content type="application/xml">
+ <m:properties>
+ <d:ProductID m:type="Int32">7</d:ProductID>
+ <d:Name>Apple</d:Name>
+ <d:QuantityPerUnit>Pound</d:QuantityPerUnit>
+ <d:UnitPrice m:type="Single">0.35</d:UnitPrice>
+ <d:QuantityInStock m:type="Int32">20</d:QuantityInStock>
+ <d:Discontinued m:type="Boolean">false</d:Discontinued>
+ <d:UserAccess m:type="#Microsoft.Test.OData.Services.ODataWCFService.AccessLevel">Read</d:UserAccess>
+ <d:SkinColor m:type="#Microsoft.Test.OData.Services.ODataWCFService.Color">Red</d:SkinColor>
+ <d:CoverColors m:type="#Collection(Microsoft.Test.OData.Services.ODataWCFService.Color)">
+ <m:element>Blue</m:element>
+ </d:CoverColors>
+ </m:properties>
+ </content>
+ </entry>
+ <entry>
+ <id>http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Products(8)</id>
+ <category term="#Microsoft.Test.OData.Services.ODataWCFService.Product" scheme="http://docs.oasis-open.org/odata/ns/scheme" />
+ <link rel="edit" href="http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Products(8)" />
+ <link rel="http://docs.oasis-open.org/odata/ns/related/Details" type="application/atom+xml;type=feed" title="Details" href="http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Products(8)/Details" />
+ <title />
+ <updated>2014-04-23T08:04:46Z</updated>
+ <author>
+ <name />
+ </author>
+ <content type="application/xml">
+ <m:properties>
+ <d:ProductID m:type="Int32">8</d:ProductID>
+ <d:Name>Car</d:Name>
+ <d:QuantityPerUnit>Pound</d:QuantityPerUnit>
+ <d:UnitPrice m:type="Single">28000</d:UnitPrice>
+ <d:QuantityInStock m:type="Int32">300</d:QuantityInStock>
+ <d:Discontinued m:type="Boolean">false</d:Discontinued>
+ <d:UserAccess m:type="#Microsoft.Test.OData.Services.ODataWCFService.AccessLevel">Execute</d:UserAccess>
+ <d:SkinColor m:type="#Microsoft.Test.OData.Services.ODataWCFService.Color">Red</d:SkinColor>
+ <d:CoverColors m:type="#Collection(Microsoft.Test.OData.Services.ODataWCFService.Color)">
+ <m:element>Red</m:element>
+ <m:element>Red</m:element>
+ <m:element>Blue</m:element>
+ </d:CoverColors>
+ </m:properties>
+ </content>
+ </entry>
+ <entry>
+ <id>http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Products(9)</id>
+ <category term="#Microsoft.Test.OData.Services.ODataWCFService.Product" scheme="http://docs.oasis-open.org/odata/ns/scheme" />
+ <link rel="edit" href="http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Products(9)" />
+ <link rel="http://docs.oasis-open.org/odata/ns/related/Details" type="application/atom+xml;type=feed" title="Details" href="http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Products(9)/Details" />
+ <title />
+ <updated>2014-04-23T08:04:46Z</updated>
+ <author>
+ <name />
+ </author>
+ <content type="application/xml">
+ <m:properties>
+ <d:ProductID m:type="Int32">9</d:ProductID>
+ <d:Name>Computer</d:Name>
+ <d:QuantityPerUnit>Pound</d:QuantityPerUnit>
+ <d:UnitPrice m:type="Single">1250</d:UnitPrice>
+ <d:QuantityInStock m:type="Int32">1000</d:QuantityInStock>
+ <d:Discontinued m:type="Boolean">false</d:Discontinued>
+ <d:UserAccess m:type="#Microsoft.Test.OData.Services.ODataWCFService.AccessLevel">Read</d:UserAccess>
+ <d:SkinColor m:type="#Microsoft.Test.OData.Services.ODataWCFService.Color">Green</d:SkinColor>
+ <d:CoverColors m:type="#Collection(Microsoft.Test.OData.Services.ODataWCFService.Color)">
+ <m:element>Green</m:element>
+ </d:CoverColors>
+ </m:properties>
+ </content>
+ </entry>
+</feed>
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f87321f9/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/AbstractODataInvokeRequest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/AbstractODataInvokeRequest.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/AbstractODataInvokeRequest.java
index 92e2e6e..6e27741 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/AbstractODataInvokeRequest.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/AbstractODataInvokeRequest.java
@@ -70,7 +70,7 @@ public abstract class AbstractODataInvokeRequest<T extends ODataInvokeResult>
* @param uri URI that identifies the operation.
*/
public AbstractODataInvokeRequest(
- final CommonODataClient odataClient,
+ final CommonODataClient<?> odataClient,
final Class<T> reference,
final HttpMethod method,
final URI uri) {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f87321f9/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v3/ODataInvokeRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v3/ODataInvokeRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v3/ODataInvokeRequestImpl.java
index 1d0fb65..84a4406 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v3/ODataInvokeRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v3/ODataInvokeRequestImpl.java
@@ -32,8 +32,8 @@ import org.apache.olingo.commons.api.format.ODataPubFormat;
public class ODataInvokeRequestImpl<T extends ODataInvokeResult> extends AbstractODataInvokeRequest<T> {
- public ODataInvokeRequestImpl(final CommonODataClient odataClient, final Class<T> reference, final HttpMethod method,
- final URI uri) {
+ public ODataInvokeRequestImpl(final CommonODataClient<?> odataClient, final Class<T> reference,
+ final HttpMethod method, final URI uri) {
super(odataClient, reference, method, uri);
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f87321f9/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v4/ODataInvokeRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v4/ODataInvokeRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v4/ODataInvokeRequestImpl.java
index 1bd0bbd..a64d991 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v4/ODataInvokeRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v4/ODataInvokeRequestImpl.java
@@ -35,8 +35,8 @@ public class ODataInvokeRequestImpl<T extends ODataInvokeResult> extends Abstrac
private ODataPubFormat format;
- public ODataInvokeRequestImpl(final CommonODataClient odataClient, final Class<T> reference, final HttpMethod method,
- final URI uri) {
+ public ODataInvokeRequestImpl(final CommonODataClient<?> odataClient, final Class<T> reference,
+ final HttpMethod method, final URI uri) {
super(odataClient, reference, method, uri);
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f87321f9/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/BatchTestITCase.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/BatchTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/BatchTestITCase.java
index 27f25c1..f980c2d 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/BatchTestITCase.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/BatchTestITCase.java
@@ -77,7 +77,7 @@ public class BatchTestITCase extends AbstractTestITCase {
private static final int MAX = 10000;
// ------------------------
- // Uncomment to performe check externally ...
+ // Uncomment to check externally ...
// ------------------------
// private final static String testStaticServiceRootURL=
// "http://odatae2etest.azurewebsites.net/javatest/DefaultService/";
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f87321f9/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/OperationImportInvokeTestITCase.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/OperationImportInvokeTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/OperationImportInvokeTestITCase.java
index d6daa34..bfc5718 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/OperationImportInvokeTestITCase.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/OperationImportInvokeTestITCase.java
@@ -22,13 +22,9 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.net.Socket;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
-import org.apache.commons.io.IOUtils;
import org.apache.olingo.client.api.communication.request.invoke.ODataInvokeRequest;
import org.apache.olingo.client.api.communication.request.invoke.ODataNoContent;
import org.apache.olingo.commons.api.domain.ODataCollectionValue;
@@ -46,35 +42,14 @@ import org.apache.olingo.commons.api.edm.EdmFunctionImport;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
import org.apache.olingo.commons.api.format.ODataPubFormat;
-import org.junit.Assume;
-import org.junit.BeforeClass;
import org.junit.Test;
public class OperationImportInvokeTestITCase extends AbstractTestITCase {
- private static final String serviceRoot = "http://odatae2etest.azurewebsites.net/javatest/DefaultService";
-
- // TODO: remove once fit provides function / action imports
- @BeforeClass
- public static void checkServerIsOnline() throws IOException {
- final Socket socket = new Socket();
- boolean reachable = false;
- try {
- socket.connect(new InetSocketAddress("odatae2etest.azurewebsites.net", 80), 2000);
- reachable = true;
- } catch (Exception e) {
- LOG.warn("External test service not reachable, ignoring this whole class: {}",
- OperationImportInvokeTestITCase.class.getName());
- } finally {
- IOUtils.closeQuietly(socket);
- }
- Assume.assumeTrue(reachable);
- }
-
private Edm getEdm() {
final Edm edm = getClient().getRetrieveRequestFactory().
- getMetadataRequest(serviceRoot).execute().getBody();
+ getMetadataRequest(testStaticServiceRootURL).execute().getBody();
assertNotNull(edm);
return edm;
@@ -89,7 +64,7 @@ public class OperationImportInvokeTestITCase extends AbstractTestITCase {
EdmFunctionImport funcImp = container.getFunctionImport("GetDefaultColor");
final ODataInvokeRequest<ODataProperty> defaultColorReq = getClient().getInvokeRequestFactory().
- getInvokeRequest(getClient().getURIBuilder(serviceRoot).
+ getInvokeRequest(getClient().getURIBuilder(testStaticServiceRootURL).
appendOperationCallSegment(funcImp.getName()).build(),
funcImp.getUnboundFunctions().get(0));
defaultColorReq.setFormat(format);
@@ -106,7 +81,7 @@ public class OperationImportInvokeTestITCase extends AbstractTestITCase {
getClient().getObjectFactory().newPrimitiveValueBuilder().buildString("London");
final ODataInvokeRequest<ODataEntity> person2Req = getClient().getInvokeRequestFactory().
- getInvokeRequest(getClient().getURIBuilder(serviceRoot).
+ getInvokeRequest(getClient().getURIBuilder(testStaticServiceRootURL).
appendOperationCallSegment(funcImp.getName()).build(),
funcImp.getUnboundFunctions().get(0),
Collections.<String, ODataValue>singletonMap("city", city));
@@ -129,24 +104,20 @@ public class OperationImportInvokeTestITCase extends AbstractTestITCase {
client.getObjectFactory().newPrimitiveValueBuilder().buildString("98052")));
final ODataInvokeRequest<ODataEntity> personReq = getClient().getInvokeRequestFactory().
- getInvokeRequest(getClient().getURIBuilder(serviceRoot).
+ getInvokeRequest(getClient().getURIBuilder(testStaticServiceRootURL).
appendOperationCallSegment(funcImp.getName()).build(),
funcImp.getUnboundFunctions().get(0),
Collections.<String, ODataValue>singletonMap("address", address));
personReq.setFormat(format);
- //TODO test service doesn't support yet complex and collection values as inline parameters
- try {
- final ODataEntity person = personReq.execute().getBody();
- assertNotNull(person);
- } catch (Exception e) {
- // ignore
- }
+ final ODataEntity person = personReq.execute().getBody();
+ assertNotNull(person);
+ assertEquals(person2, person);
// GetAllProducts
funcImp = container.getFunctionImport("GetAllProducts");
final ODataInvokeRequest<ODataEntitySet> productsReq = getClient().getInvokeRequestFactory().
- getInvokeRequest(getClient().getURIBuilder(serviceRoot).
+ getInvokeRequest(getClient().getURIBuilder(testStaticServiceRootURL).
appendOperationCallSegment(funcImp.getName()).build(),
funcImp.getUnboundFunctions().get(0));
productsReq.setFormat(format);
@@ -161,7 +132,7 @@ public class OperationImportInvokeTestITCase extends AbstractTestITCase {
newEnumValue("Microsoft.Test.OData.Services.ODataWCFService.AccessLevel", "None");
final ODataInvokeRequest<ODataProperty> prodByALReq = getClient().getInvokeRequestFactory().
- getInvokeRequest(getClient().getURIBuilder(serviceRoot).
+ getInvokeRequest(getClient().getURIBuilder(testStaticServiceRootURL).
appendOperationCallSegment(funcImp.getName()).build(),
funcImp.getUnboundFunctions().get(0),
Collections.<String, ODataValue>singletonMap("accessLevel", accessLevel));
@@ -193,7 +164,7 @@ public class OperationImportInvokeTestITCase extends AbstractTestITCase {
final ODataPrimitiveValue percentage = getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(22);
final ODataInvokeRequest<ODataNoContent> discountReq = getClient().getInvokeRequestFactory().
- getInvokeRequest(getClient().getURIBuilder(serviceRoot).
+ getInvokeRequest(getClient().getURIBuilder(testStaticServiceRootURL).
appendOperationCallSegment(actImp.getName()).build(),
actImp.getUnboundAction(),
Collections.<String, ODataValue>singletonMap("percentage", percentage));
@@ -214,7 +185,7 @@ public class OperationImportInvokeTestITCase extends AbstractTestITCase {
client.getObjectFactory().newPrimitiveValueBuilder().buildString("66010")));
final ODataInvokeRequest<ODataProperty> resetBossAddressReq = getClient().getInvokeRequestFactory().
- getInvokeRequest(getClient().getURIBuilder(serviceRoot).
+ getInvokeRequest(getClient().getURIBuilder(testStaticServiceRootURL).
appendOperationCallSegment(actImp.getName()).build(),
actImp.getUnboundAction(),
Collections.<String, ODataValue>singletonMap("address", address));
@@ -225,12 +196,7 @@ public class OperationImportInvokeTestITCase extends AbstractTestITCase {
@Test
public void atomActionImports() {
- //TODO test service doesn't support yet Atom POST params
- try {
- actionImports(ODataPubFormat.ATOM);
- } catch (Exception e) {
- // ignore
- }
+ actionImports(ODataPubFormat.ATOM);
}
@Test
@@ -247,12 +213,11 @@ public class OperationImportInvokeTestITCase extends AbstractTestITCase {
final EdmActionImport actImp = container.getActionImport("ResetBossEmail");
final ODataCollectionValue<org.apache.olingo.commons.api.domain.v4.ODataValue> emails =
- getClient().getObjectFactory().newCollectionValue(
- EdmPrimitiveTypeKind.String.getFullQualifiedName().toString());
+ getClient().getObjectFactory().newCollectionValue("Collection(Edm.String)");
emails.add(getClient().getObjectFactory().newPrimitiveValueBuilder().buildString("first@olingo.apache.org"));
emails.add(getClient().getObjectFactory().newPrimitiveValueBuilder().buildString("second@olingo.apache.org"));
ODataInvokeRequest<ODataProperty> bossEmailsReq = getClient().getInvokeRequestFactory().
- getInvokeRequest(getClient().getURIBuilder(serviceRoot).
+ getInvokeRequest(getClient().getURIBuilder(testStaticServiceRootURL).
appendOperationCallSegment(actImp.getName()).build(),
actImp.getUnboundAction(),
Collections.<String, ODataValue>singletonMap("emails", emails));
@@ -268,7 +233,7 @@ public class OperationImportInvokeTestITCase extends AbstractTestITCase {
params.put("start", getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(0));
params.put("count", getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(100));
bossEmailsReq = getClient().getInvokeRequestFactory().
- getInvokeRequest(getClient().getURIBuilder(serviceRoot).
+ getInvokeRequest(getClient().getURIBuilder(testStaticServiceRootURL).
appendOperationCallSegment(funcImp.getName()).build(),
funcImp.getUnboundFunctions().get(0),
params);
@@ -277,17 +242,13 @@ public class OperationImportInvokeTestITCase extends AbstractTestITCase {
assertNotNull(bossEmailsViaGET);
assertTrue(bossEmailsViaGET.hasCollectionValue());
assertEquals(2, bossEmailsViaGET.getCollectionValue().size());
- assertEquals(bossEmails, bossEmailsViaGET);
+ assertEquals(bossEmails.getCollectionValue().asJavaCollection(),
+ bossEmailsViaGET.getCollectionValue().asJavaCollection());
}
@Test
public void atomBossEmails() throws EdmPrimitiveTypeException {
- //TODO test service doesn't support yet Atom POST params
- try {
- bossEmails(ODataPubFormat.ATOM);
- } catch (Exception e) {
- // ignore
- }
+ bossEmails(ODataPubFormat.ATOM);
}
@Test
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f87321f9/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractJsonSerializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractJsonSerializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractJsonSerializer.java
index 362552f..06e0e5e 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractJsonSerializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractJsonSerializer.java
@@ -195,7 +195,7 @@ abstract class AbstractJsonSerializer<T> extends ODataJacksonSerializer<T> {
}
protected void property(final JsonGenerator jgen, final Property property, final String name) throws IOException {
- if (serverMode) {
+ if (serverMode && !Constants.VALUE.equals(name)) {
String type = property.getType();
if (StringUtils.isBlank(type)
&& property.getValue().isPrimitive() || property.getValue().isNull()) {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f87321f9/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomSerializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomSerializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomSerializer.java
index 65cb6b2..b3777fd 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomSerializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomSerializer.java
@@ -229,8 +229,10 @@ public class AtomSerializer extends AbstractAtomDealer {
writer.writeStartElement(Constants.ATOM_ELEM_CATEGORY);
writer.writeAttribute(Constants.ATOM_ATTR_SCHEME, version.getNamespaceMap().get(ODataServiceVersion.NS_SCHEME));
- writer.writeAttribute(Constants.ATOM_ATTR_TERM,
- new EdmTypeInfo.Builder().setTypeExpression(entry.getType()).build().external(version));
+ if (StringUtils.isNotBlank(entry.getType())) {
+ writer.writeAttribute(Constants.ATOM_ATTR_TERM,
+ new EdmTypeInfo.Builder().setTypeExpression(entry.getType()).build().external(version));
+ }
writer.writeEndElement();
if (entry instanceof AbstractODataObject) {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f87321f9/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntrySerializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntrySerializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntrySerializer.java
index d12bdad..db4ab7c 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntrySerializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntrySerializer.java
@@ -52,21 +52,14 @@ public class JSONEntrySerializer extends AbstractJsonSerializer<JSONEntryImpl> {
jgen.writeStartObject();
- if (StringUtils.isNotBlank(entry.getType())) {
- jgen.writeStringField(version.getJSONMap().get(ODataServiceVersion.JSON_TYPE),
- new EdmTypeInfo.Builder().setTypeExpression(entry.getType()).build().external(version));
- }
-
if (serverMode) {
if (container.getContextURL() != null) {
jgen.writeStringField(version.compareTo(ODataServiceVersion.V40) >= 0
? Constants.JSON_CONTEXT : Constants.JSON_METADATA,
container.getContextURL().toASCIIString());
}
- if (version.compareTo(ODataServiceVersion.V40) >= 0) {
- if (StringUtils.isNotBlank(container.getMetadataETag())) {
- jgen.writeStringField(Constants.JSON_METADATA_ETAG, container.getMetadataETag());
- }
+ if (version.compareTo(ODataServiceVersion.V40) >= 0 && StringUtils.isNotBlank(container.getMetadataETag())) {
+ jgen.writeStringField(Constants.JSON_METADATA_ETAG, container.getMetadataETag());
}
if (StringUtils.isNotBlank(entry.getETag())) {
@@ -74,6 +67,11 @@ public class JSONEntrySerializer extends AbstractJsonSerializer<JSONEntryImpl> {
}
}
+ if (StringUtils.isNotBlank(entry.getType())) {
+ jgen.writeStringField(version.getJSONMap().get(ODataServiceVersion.JSON_TYPE),
+ new EdmTypeInfo.Builder().setTypeExpression(entry.getType()).build().external(version));
+ }
+
if (entry.getId() != null) {
jgen.writeStringField(version.getJSONMap().get(ODataServiceVersion.JSON_ID), entry.getId());
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f87321f9/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONPropertySerializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONPropertySerializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONPropertySerializer.java
index 1085fa5..4f20e69 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONPropertySerializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONPropertySerializer.java
@@ -22,9 +22,11 @@ import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.SerializerProvider;
import java.io.IOException;
+import org.apache.commons.lang3.StringUtils;
import org.apache.olingo.commons.api.Constants;
import org.apache.olingo.commons.api.data.Container;
import org.apache.olingo.commons.api.data.Property;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
import org.apache.olingo.commons.core.edm.EdmTypeInfo;
/**
@@ -49,6 +51,17 @@ public class JSONPropertySerializer extends AbstractJsonSerializer<JSONPropertyI
jgen.writeStartObject();
+ if (serverMode && container.getContextURL() != null) {
+ jgen.writeStringField(version.compareTo(ODataServiceVersion.V40) >= 0
+ ? Constants.JSON_CONTEXT : Constants.JSON_METADATA,
+ container.getContextURL().toASCIIString());
+ }
+
+ if (StringUtils.isNotBlank(property.getType())) {
+ jgen.writeStringField(version.getJSONMap().get(ODataServiceVersion.JSON_TYPE),
+ new EdmTypeInfo.Builder().setTypeExpression(property.getType()).build().external(version));
+ }
+
if (property.getValue().isNull()) {
jgen.writeBooleanField(Constants.JSON_NULL, true);
} else if (property.getValue().isPrimitive()) {