本文整理汇总了Java中org.apache.olingo.commons.api.http.HttpMethod.PUT属性的典型用法代码示例。如果您正苦于以下问题:Java HttpMethod.PUT属性的具体用法?Java HttpMethod.PUT怎么用?Java HttpMethod.PUT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.olingo.commons.api.http.HttpMethod
的用法示例。
在下文中一共展示了HttpMethod.PUT属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPropertyCollectionValueUpdateRequest
@Override
public ODataPropertyUpdateRequest getPropertyCollectionValueUpdateRequest(
final URI targetURI, final ClientProperty property) {
if (!property.hasCollectionValue()) {
throw new IllegalArgumentException("A collection value is required");
}
final ODataPropertyUpdateRequest req;
if (client.getConfiguration().isUseXHTTPMethod()) {
req = new ODataPropertyUpdateRequestImpl(client, HttpMethod.POST, targetURI, property);
req.setXHTTPMethod(HttpMethod.PUT.name());
} else {
req = new ODataPropertyUpdateRequestImpl(client, HttpMethod.PUT, targetURI, property);
}
return req;
}
示例2: batchBoundaryEqualsChangeSetBoundary
@Test
public void batchBoundaryEqualsChangeSetBoundary() throws Exception {
final String batch = "--" + BOUNDARY + CRLF
+ HttpHeader.CONTENT_TYPE + ": " + MULTIPART_MIXED + ";boundary=" + BOUNDARY + CRLF
+ CRLF
+ "--" + BOUNDARY + CRLF
+ MIME_HEADERS
+ HttpHeader.CONTENT_ID + ": 1" + CRLF
+ CRLF
+ HttpMethod.PUT + " " + PROPERTY_URI + HTTP_VERSION + CRLF
+ ACCEPT_HEADER
+ HttpHeader.CONTENT_TYPE + ": " + APPLICATION_JSON + CRLF
+ CRLF
+ "{\"value\":\"MODIFIED\"}" + CRLF
+ CRLF
+ "--" + BOUNDARY + "--"
+ CRLF
+ "--" + BOUNDARY + "--";
parseInvalidBatchBody(batch, BatchDeserializerException.MessageKeys.MISSING_BLANK_LINE);
}
示例3: getPropertyPrimitiveValueUpdateRequest
@Override
public ODataPropertyUpdateRequest getPropertyPrimitiveValueUpdateRequest(
final URI targetURI, final ClientProperty property) {
if (!property.hasPrimitiveValue()) {
throw new IllegalArgumentException("A primitive value is required");
}
final ODataPropertyUpdateRequest req;
if (client.getConfiguration().isUseXHTTPMethod()) {
req = new ODataPropertyUpdateRequestImpl(client, HttpMethod.POST, targetURI, property);
req.setXHTTPMethod(HttpMethod.PUT.name());
} else {
req = new ODataPropertyUpdateRequestImpl(client, HttpMethod.PUT, targetURI, property);
}
return req;
}
示例4: handleMediaValueDispatching
private void handleMediaValueDispatching(final ODataRequest request, final ODataResponse response,
final UriResource resource) throws ContentNegotiatorException,
ODataApplicationException, ODataLibraryException,
ODataHandlerException, PreconditionException {
final HttpMethod method = request.getMethod();
if (method == HttpMethod.GET) {
// This can be a GET on an EntitySet, Navigation or Function
final ContentType requestedContentType = ContentNegotiator.
doContentNegotiation(uriInfo.getFormatOption(),
request, handler.getCustomContentTypeSupport(), RepresentationType.MEDIA);
handler.selectProcessor(MediaEntityProcessor.class)
.readMediaEntity(request, response, uriInfo, requestedContentType);
// PUT and DELETE can only be called on EntitySets or Navigation properties which are media resources
} else if (method == HttpMethod.PUT && (isEntityOrNavigationMedia(resource)
|| isSingletonMedia(resource))) {
validatePreconditions(request, true);
final ContentType requestFormat = ContentType.parse(request.getHeader(HttpHeader.CONTENT_TYPE));
final ContentType responseFormat = ContentNegotiator.doContentNegotiation(uriInfo.getFormatOption(),
request, handler.getCustomContentTypeSupport(), RepresentationType.ENTITY);
handler.selectProcessor(MediaEntityProcessor.class)
.updateMediaEntity(request, response, uriInfo, requestFormat, responseFormat);
} else if (method == HttpMethod.DELETE && isEntityOrNavigationMedia(resource)) {
validatePreconditions(request, true);
handler.selectProcessor(MediaEntityProcessor.class)
.deleteMediaEntity(request, response, uriInfo);
} else {
throwMethodNotAllowed(method);
}
}
示例5: handleSingleEntityDispatching
private void handleSingleEntityDispatching(final ODataRequest request, final ODataResponse response,
final boolean isMedia, final boolean isSingleton) throws
ContentNegotiatorException, ODataApplicationException,
ODataLibraryException, ODataHandlerException, PreconditionException {
final HttpMethod method = request.getMethod();
if (method == HttpMethod.GET) {
final ContentType requestedContentType = ContentNegotiator.
doContentNegotiation(uriInfo.getFormatOption(),
request, handler.getCustomContentTypeSupport(), RepresentationType.ENTITY);
handler.selectProcessor(EntityProcessor.class)
.readEntity(request, response, uriInfo, requestedContentType);
} else if (method == HttpMethod.PUT || method == HttpMethod.PATCH) {
validatePreconditions(request, false);
final ContentType requestFormat = getSupportedContentType(
request.getHeader(HttpHeader.CONTENT_TYPE),
RepresentationType.ENTITY, true);
final ContentType responseFormat = ContentNegotiator.
doContentNegotiation(uriInfo.getFormatOption(),
request, handler.getCustomContentTypeSupport(), RepresentationType.ENTITY);
handler.selectProcessor(EntityProcessor.class)
.updateEntity(request, response, uriInfo, requestFormat, responseFormat);
} else if (method == HttpMethod.DELETE && !isSingleton) {
validateIsSingleton(method);
validatePreconditions(request, false);
handler.selectProcessor(isMedia ? MediaEntityProcessor.class : EntityProcessor.class)
.deleteEntity(request, response, uriInfo);
} else {
throwMethodNotAllowed(method);
}
}
示例6: noContentId
@Test
public void noContentId() throws Exception {
final String batch = "--" + BOUNDARY + CRLF
+ MIME_HEADERS
+ CRLF
+ HttpMethod.GET + " ESMedia" + HTTP_VERSION + CRLF
+ ACCEPT_HEADER
+ CRLF
+ CRLF
+ "--" + BOUNDARY + CRLF
+ HttpHeader.CONTENT_TYPE + ": " + MULTIPART_MIXED + "; boundary=" + CHANGESET_BOUNDARY + CRLF
+ CRLF
+ "--" + CHANGESET_BOUNDARY + CRLF
+ MIME_HEADERS
+ HttpHeader.CONTENT_ID + ": 1" + CRLF
+ CRLF
+ HttpMethod.POST + " ESMedia" + HTTP_VERSION + CRLF
+ HttpHeader.CONTENT_TYPE + ": image/png" + CRLF
+ "Content-Transfer-Encoding: base64" + CRLF
+ CRLF
+ "iVBORw0KGgoAAAANSUhEUgAAABQAAAAMCAIAAADtbgqsAAAABmJLR0QA/wD/AP+gvaeTAAAAH0lE"
+ "QVQokWNgGHmA8S4FmpkosXngNDP+PzdANg+cZgBqiQK5mkdWWgAAAABJRU5ErkJggg==" + CRLF
+ CRLF
+ "--" + CHANGESET_BOUNDARY + CRLF
+ MIME_HEADERS
+ HttpHeader.CONTENT_ID + ": 1" + CRLF
+ CRLF
+ HttpMethod.PUT + " $1/PropertyInt16" + HTTP_VERSION + CRLF
+ HttpHeader.CONTENT_TYPE + ": " + APPLICATION_JSON + CRLF
+ CRLF
+ "{\"value\":5}" + CRLF
+ "--" + CHANGESET_BOUNDARY + "--" + CRLF
+ CRLF
+ "--" + BOUNDARY + "--";
parse(batch);
}
示例7: getMediaEntityUpdateRequest
@Override
public <E extends ClientEntity> ODataMediaEntityUpdateRequest<E> getMediaEntityUpdateRequest(
final URI editURI, final InputStream media) {
final ODataMediaEntityUpdateRequest<E> req;
if (client.getConfiguration().isUseXHTTPMethod()) {
req = new ODataMediaEntityUpdateRequestImpl<E>(client, HttpMethod.POST, URIUtils.addValueSegment(editURI), media);
req.setXHTTPMethod(HttpMethod.PUT.name());
} else {
req = new ODataMediaEntityUpdateRequestImpl<E>(client, HttpMethod.PUT, URIUtils.addValueSegment(editURI), media);
}
return req;
}
示例8: getReferenceSingleChangeRequest
@Override
public ODataReferenceAddingRequest getReferenceSingleChangeRequest(final URI serviceRoot, final URI targetURI,
final URI reference) {
// See OData Protocol 11.4.6.3
final URI contextURI = client.newURIBuilder(serviceRoot.toASCIIString()).appendMetadataSegment().build();
ResWrap<URI> wrappedPayload = new ResWrap<URI>(contextURI, null, reference);
return new ODataReferenceAddingRequestImpl(client, HttpMethod.PUT, targetURI, wrappedPayload);
}
示例9: handleComplexDispatching
private void handleComplexDispatching(final ODataRequest request, final ODataResponse response,
final boolean isCollection) throws ODataApplicationException, ODataLibraryException {
final HttpMethod method = request.getMethod();
final RepresentationType complexRepresentationType = isCollection ? RepresentationType.COLLECTION_COMPLEX
: RepresentationType.COMPLEX;
if (method == HttpMethod.GET) {
final ContentType requestedContentType = ContentNegotiator.doContentNegotiation(uriInfo.getFormatOption(),
request, handler.getCustomContentTypeSupport(), complexRepresentationType);
if (isCollection) {
handler.selectProcessor(ComplexCollectionProcessor.class)
.readComplexCollection(request, response, uriInfo, requestedContentType);
} else {
handler.selectProcessor(ComplexProcessor.class)
.readComplex(request, response, uriInfo, requestedContentType);
}
} else if (method == HttpMethod.PUT || method == HttpMethod.PATCH) {
validatePreconditions(request, false);
final ContentType requestFormat = getSupportedContentType(request.getHeader(HttpHeader.CONTENT_TYPE),
complexRepresentationType, true);
final ContentType responseFormat = ContentNegotiator.doContentNegotiation(uriInfo.getFormatOption(),
request, handler.getCustomContentTypeSupport(), complexRepresentationType);
if (isCollection) {
handler.selectProcessor(ComplexCollectionProcessor.class)
.updateComplexCollection(request, response, uriInfo, requestFormat, responseFormat);
} else {
handler.selectProcessor(ComplexProcessor.class)
.updateComplex(request, response, uriInfo, requestFormat, responseFormat);
}
} else if (method == HttpMethod.DELETE) {
validatePreconditions(request, false);
if (isCollection) {
handler.selectProcessor(ComplexCollectionProcessor.class)
.deleteComplexCollection(request, response, uriInfo);
} else {
handler.selectProcessor(ComplexProcessor.class)
.deleteComplex(request, response, uriInfo);
}
} else {
throwMethodNotAllowed(method);
}
}
示例10: handlePrimitiveDispatching
private void handlePrimitiveDispatching(final ODataRequest request, final ODataResponse response,
final boolean isCollection) throws ODataApplicationException, ODataLibraryException {
final HttpMethod method = request.getMethod();
final RepresentationType representationType = isCollection ? RepresentationType.COLLECTION_PRIMITIVE
: RepresentationType.PRIMITIVE;
if (method == HttpMethod.GET) {
final ContentType requestedContentType = ContentNegotiator.doContentNegotiation(uriInfo.getFormatOption(),
request, handler.getCustomContentTypeSupport(), representationType);
if (isCollection) {
handler.selectProcessor(PrimitiveCollectionProcessor.class)
.readPrimitiveCollection(request, response, uriInfo, requestedContentType);
} else {
handler.selectProcessor(PrimitiveProcessor.class)
.readPrimitive(request, response, uriInfo, requestedContentType);
}
} else if (method == HttpMethod.PUT || method == HttpMethod.PATCH) {
validatePreconditions(request, false);
final ContentType requestFormat = getSupportedContentType(request.getHeader(HttpHeader.CONTENT_TYPE),
representationType, true);
final ContentType responseFormat = ContentNegotiator.doContentNegotiation(uriInfo.getFormatOption(),
request, handler.getCustomContentTypeSupport(), representationType);
if (isCollection) {
handler.selectProcessor(PrimitiveCollectionProcessor.class)
.updatePrimitiveCollection(request, response, uriInfo, requestFormat, responseFormat);
} else {
handler.selectProcessor(PrimitiveProcessor.class)
.updatePrimitive(request, response, uriInfo, requestFormat, responseFormat);
}
} else if (method == HttpMethod.DELETE) {
validatePreconditions(request, false);
if (isCollection) {
handler.selectProcessor(PrimitiveCollectionProcessor.class)
.deletePrimitiveCollection(request, response, uriInfo);
} else {
handler.selectProcessor(PrimitiveProcessor.class)
.deletePrimitive(request, response, uriInfo);
}
} else {
throwMethodNotAllowed(method);
}
}
示例11: basic
@Test
public void basic() throws Exception {
final String batch = "--" + BOUNDARY + CRLF
+ MIME_HEADERS
+ CRLF
+ HttpMethod.GET + " " + PROPERTY_URI + "?$format=json" + HTTP_VERSION + CRLF
+ HttpHeader.ACCEPT_LANGUAGE + ":en-US,en;q=0.7,en-GB;q=0.9" + CRLF
+ CRLF
+ CRLF
+ "--" + BOUNDARY +CRLF
+ HttpHeader.CONTENT_TYPE + ": " + MULTIPART_MIXED + "; boundary=" + CHANGESET_BOUNDARY + CRLF
+ CRLF
+ "--" + CHANGESET_BOUNDARY + CRLF
+ MIME_HEADERS
+ HttpHeader.CONTENT_ID + ": changeRequest1" + CRLF
+ CRLF
+ HttpMethod.PUT + " " + PROPERTY_URI + HTTP_VERSION + CRLF
+ HttpHeader.CONTENT_LENGTH + ": 100000" + CRLF
+ ACCEPT_HEADER
+ HttpHeader.CONTENT_TYPE + ": " + APPLICATION_JSON + CRLF
+ CRLF
+ "{\"value\":\"€ MODIFIED\"}" + CRLF
+ CRLF
+ "--" + CHANGESET_BOUNDARY + "--" + CRLF
+ CRLF
+ "--" + BOUNDARY + CRLF
+ MIME_HEADERS
+ CRLF
+ HttpMethod.GET + " " + PROPERTY_URI + "?$format=json" + HTTP_VERSION + CRLF
+ CRLF
+ CRLF
+ "--" + BOUNDARY + "--";
final List<BatchRequestPart> batchRequestParts = parse(batch);
Assert.assertNotNull(batchRequestParts);
Assert.assertFalse(batchRequestParts.isEmpty());
for (final BatchRequestPart object : batchRequestParts) {
Assert.assertEquals(1, object.getRequests().size());
final ODataRequest request = object.getRequests().get(0);
Assert.assertEquals(SERVICE_ROOT, request.getRawBaseUri());
Assert.assertEquals("/" + PROPERTY_URI, request.getRawODataPath());
if (!object.isChangeSet()) {
Assert.assertEquals(HttpMethod.GET, request.getMethod());
if (request.getHeaders(HttpHeader.ACCEPT_LANGUAGE) != null) {
Assert.assertEquals(3, request.getHeaders(HttpHeader.ACCEPT_LANGUAGE).size());
}
Assert.assertEquals(SERVICE_ROOT + "/" + PROPERTY_URI + "?$format=json", request.getRawRequestUri());
Assert.assertEquals("$format=json", request.getRawQueryPath());
} else {
Assert.assertEquals(HttpMethod.PUT, request.getMethod());
Assert.assertEquals("100000", request.getHeader(HttpHeader.CONTENT_LENGTH));
Assert.assertEquals(APPLICATION_JSON, request.getHeader(HttpHeader.CONTENT_TYPE));
final List<String> acceptHeader = request.getHeaders(HttpHeader.ACCEPT);
Assert.assertEquals(4, request.getHeaders(HttpHeader.ACCEPT).size());
Assert.assertEquals("application/atom+xml;q=0.8", acceptHeader.get(2));
Assert.assertEquals("*/*;q=0.1", acceptHeader.get(3));
Assert.assertEquals(SERVICE_ROOT + "/" + PROPERTY_URI, request.getRawRequestUri());
Assert.assertEquals("", request.getRawQueryPath()); // No query parameter
Assert.assertEquals("{\"value\":\"€ MODIFIED\"}" + CRLF, IOUtils.toString(request.getBody()));
}
}
}
示例12: methodsForIndividualRequests
@Test
public void methodsForIndividualRequests() throws Exception {
final String batch = "--" + BOUNDARY + CRLF
+ MIME_HEADERS
+ CRLF
+ HttpMethod.POST + " ESAllPrim" + HTTP_VERSION + CRLF
+ HttpHeader.CONTENT_TYPE + ": " + APPLICATION_JSON + CRLF
+ CRLF
+ "{ \"PropertyString\": \"Foo\" }"
+ CRLF
+ "--" + BOUNDARY + CRLF
+ MIME_HEADERS
+ CRLF
+ HttpMethod.DELETE + " ESAllPrim(32767)" + HTTP_VERSION + CRLF
+ CRLF
+ CRLF
+ "--" + BOUNDARY + CRLF
+ MIME_HEADERS
+ CRLF
+ HttpMethod.PATCH + " ESAllPrim(32767)" + HTTP_VERSION + CRLF
+ HttpHeader.CONTENT_TYPE + ": " + APPLICATION_JSON + CRLF
+ CRLF
+ "{ \"PropertyString\": \"Foo\" }" + CRLF
+ "--" + BOUNDARY + CRLF
+ MIME_HEADERS
+ CRLF
+ HttpMethod.PUT + " ESAllPrim(32767)" + HTTP_VERSION + CRLF
+ HttpHeader.CONTENT_TYPE + ": " + APPLICATION_JSON + CRLF
+ CRLF
+ "{ \"PropertyString\": \"Foo\" }" + CRLF
+ "--" + BOUNDARY + CRLF
+ MIME_HEADERS
+ CRLF
+ HttpMethod.GET + " ESAllPrim(32767)" + HTTP_VERSION + CRLF
+ ACCEPT_HEADER
+ CRLF
+ CRLF
+ "--" + BOUNDARY + "--";
final List<BatchRequestPart> requests = parse(batch);
Assert.assertEquals(HttpMethod.POST, requests.get(0).getRequests().get(0).getMethod());
Assert.assertEquals("/ESAllPrim", requests.get(0).getRequests().get(0).getRawODataPath());
Assert.assertEquals("{ \"PropertyString\": \"Foo\" }",
IOUtils.toString(requests.get(0).getRequests().get(0).getBody()));
Assert.assertEquals(HttpMethod.DELETE, requests.get(1).getRequests().get(0).getMethod());
Assert.assertEquals("/ESAllPrim(32767)", requests.get(1).getRequests().get(0).getRawODataPath());
Assert.assertEquals(HttpMethod.PATCH, requests.get(2).getRequests().get(0).getMethod());
Assert.assertEquals("/ESAllPrim(32767)", requests.get(2).getRequests().get(0).getRawODataPath());
Assert.assertEquals("{ \"PropertyString\": \"Foo\" }",
IOUtils.toString(requests.get(2).getRequests().get(0).getBody()));
Assert.assertEquals(HttpMethod.PUT, requests.get(3).getRequests().get(0).getMethod());
Assert.assertEquals("/ESAllPrim(32767)", requests.get(3).getRequests().get(0).getRawODataPath());
Assert.assertEquals("{ \"PropertyString\": \"Foo\" }",
IOUtils.toString(requests.get(3).getRequests().get(0).getBody()));
Assert.assertEquals(HttpMethod.GET, requests.get(4).getRequests().get(0).getMethod());
Assert.assertEquals("/ESAllPrim(32767)", requests.get(4).getRequests().get(0).getRawODataPath());
}
示例13: contentId
@Test
public void contentId() throws Exception {
final String batch = "--" + BOUNDARY + CRLF
+ MIME_HEADERS
+ CRLF
+ HttpMethod.GET + " ESAllPrim" + HTTP_VERSION + CRLF
+ ACCEPT_HEADER
+ HttpHeader.CONTENT_ID + ": BBB" + CRLF
+ CRLF + CRLF
+ "--" + BOUNDARY + CRLF
+ HttpHeader.CONTENT_TYPE + ": " + MULTIPART_MIXED + "; boundary=" + CHANGESET_BOUNDARY + CRLF
+ CRLF
+ "--" + CHANGESET_BOUNDARY + CRLF
+ MIME_HEADERS
+ HttpHeader.CONTENT_ID + ": 1" + CRLF
+ CRLF
+ HttpMethod.POST + " ESMedia" + HTTP_VERSION + CRLF
+ HttpHeader.CONTENT_TYPE + ": image/png" + CRLF
+ "Content-Transfer-Encoding: base64" + CRLF
+ CRLF
+ "iVBORw0KGgoAAAANSUhEUgAAABQAAAAMCAIAAADtbgqsAAAABmJLR0QA/wD/AP+gvaeTAAAAH0lE"
+ "QVQokWNgGHmA8S4FmpkosXngNDP+PzdANg+cZgBqiQK5mkdWWgAAAABJRU5ErkJggg==" + CRLF
+ CRLF
+ "--" + CHANGESET_BOUNDARY + CRLF
+ MIME_HEADERS
+ CRLF
+ HttpMethod.PUT + " $1/PropertyInt16" + HTTP_VERSION + CRLF
+ HttpHeader.CONTENT_TYPE + ": " + APPLICATION_JSON + CRLF
+ HttpHeader.CONTENT_ID + ": 2" + CRLF
+ CRLF
+ "{\"value\":5}" + CRLF
+ "--" + CHANGESET_BOUNDARY + "--" + CRLF
+ CRLF
+ "--" + BOUNDARY + "--";
final List<BatchRequestPart> batchRequestParts = parse(batch);
Assert.assertNotNull(batchRequestParts);
for (BatchRequestPart multipart : batchRequestParts) {
if (!multipart.isChangeSet()) {
Assert.assertEquals(1, multipart.getRequests().size());
Assert.assertEquals("BBB", multipart.getRequests().get(0).getHeader(HttpHeader.CONTENT_ID));
} else {
for (ODataRequest request : multipart.getRequests()) {
if (HttpMethod.POST.equals(request.getMethod())) {
Assert.assertEquals("1", request.getHeader(HttpHeader.CONTENT_ID));
} else if (HttpMethod.PUT.equals(request.getMethod())) {
Assert.assertEquals("2", request.getHeader(HttpHeader.CONTENT_ID));
Assert.assertEquals("/$1/PropertyInt16", request.getRawODataPath());
Assert.assertEquals(SERVICE_ROOT + "/$1/PropertyInt16", request.getRawRequestUri());
}
}
}
}
}
示例14: preamble
@Test
public void preamble() throws Exception {
final String batch = "This is a preamble and must be ignored" + CRLF
+ CRLF
+ CRLF
+ "----1242" + CRLF
+ "--" + BOUNDARY + CRLF
+ MIME_HEADERS
+ CRLF
+ HttpMethod.GET + " ESAllPrim" + HTTP_VERSION + CRLF
+ ACCEPT_HEADER
+ CRLF
+ CRLF
+ "--" + BOUNDARY + CRLF
+ HttpHeader.CONTENT_TYPE + ": " + MULTIPART_MIXED + "; boundary=" + CHANGESET_BOUNDARY + CRLF
+ CRLF
+ "This is a preamble and must be ignored" + CRLF
+ CRLF
+ CRLF
+ "----1242" + CRLF
+ "--" + CHANGESET_BOUNDARY + CRLF
+ MIME_HEADERS
+ HttpHeader.CONTENT_ID + ": 1" + CRLF
+ CRLF
+ HttpMethod.POST + " ESMedia" + HTTP_VERSION + CRLF
+ HttpHeader.CONTENT_TYPE + ": image/png" + CRLF
+ "Content-Transfer-Encoding: base64" + CRLF
+ CRLF
+ "iVBORw0KGgoAAAANSUhEUgAAABQAAAAMCAIAAADtbgqsAAAABmJLR0QA/wD/AP+gvaeTAAAAH0lE"
+ "QVQokWNgGHmA8S4FmpkosXngNDP+PzdANg+cZgBqiQK5mkdWWgAAAABJRU5ErkJggg==" + CRLF
+ CRLF
+ "--" + CHANGESET_BOUNDARY + CRLF
+ MIME_HEADERS
+ HttpHeader.CONTENT_ID + ": 2" + CRLF
+ CRLF
+ HttpMethod.PUT + " $1/PropertyInt16" + HTTP_VERSION + CRLF
+ HttpHeader.CONTENT_TYPE + ": " + APPLICATION_JSON + CRLF
+ CRLF
+ "{\"value\":5}" + CRLF
+ "--" + CHANGESET_BOUNDARY + "--" + CRLF
+ CRLF
+ "--" + BOUNDARY + "--";
final List<BatchRequestPart> batchRequestParts = parse(batch);
Assert.assertNotNull(batchRequestParts);
Assert.assertEquals(2, batchRequestParts.size());
final BatchRequestPart getRequestPart = batchRequestParts.get(0);
Assert.assertEquals(1, getRequestPart.getRequests().size());
final ODataRequest getRequest = getRequestPart.getRequests().get(0);
Assert.assertEquals(HttpMethod.GET, getRequest.getMethod());
final BatchRequestPart changeSetPart = batchRequestParts.get(1);
Assert.assertEquals(2, changeSetPart.getRequests().size());
Assert.assertEquals("iVBORw0KGgoAAAANSUhEUgAAABQAAAAMCAIAAADtbgqsAAAABmJLR0QA/wD/AP+gvaeTAAAAH0lE"
+ "QVQokWNgGHmA8S4FmpkosXngNDP+PzdANg+cZgBqiQK5mkdWWgAAAABJRU5ErkJggg==" + CRLF,
IOUtils.toString(changeSetPart.getRequests().get(0).getBody()));
Assert.assertEquals("{\"value\":5}", IOUtils.toString(changeSetPart.getRequests().get(1).getBody()));
}
示例15: epilog
@Test
public void epilog() throws Exception {
String batch = "--" + BOUNDARY + CRLF
+ GET_REQUEST
+ "--" + BOUNDARY + CRLF
+ HttpHeader.CONTENT_TYPE + ": " + MULTIPART_MIXED + "; boundary=" + CHANGESET_BOUNDARY + CRLF
+ CRLF
+ "--" + CHANGESET_BOUNDARY + CRLF
+ MIME_HEADERS
+ HttpHeader.CONTENT_ID + ": 1" + CRLF
+ CRLF
+ HttpMethod.POST + " ESMedia" + HTTP_VERSION + CRLF
+ HttpHeader.CONTENT_TYPE + ": image/png" + CRLF
+ "Content-Transfer-Encoding: base64" + CRLF
+ CRLF
+ "iVBORw0KGgoAAAANSUhEUgAAABQAAAAMCAIAAADtbgqsAAAABmJLR0QA/wD/AP+gvaeTAAAAH0lE"
+ "QVQokWNgGHmA8S4FmpkosXngNDP+PzdANg+cZgBqiQK5mkdWWgAAAABJRU5ErkJggg==" + CRLF
+ CRLF
+ "--" + CHANGESET_BOUNDARY + CRLF
+ MIME_HEADERS
+ HttpHeader.CONTENT_ID + ": 2" + CRLF
+ CRLF
+ HttpMethod.PUT + " $1/PropertyInt16" + HTTP_VERSION + CRLF
+ HttpHeader.CONTENT_TYPE + ": " + APPLICATION_JSON + CRLF
+ CRLF
+ "{\"value\":5}" + CRLF
+ "--" + CHANGESET_BOUNDARY + "--" + CRLF
+ CRLF
+ "This is an epilog and must be ignored" + CRLF
+ CRLF
+ CRLF
+ "----1242"
+ CRLF
+ "--" + BOUNDARY + "--"
+ CRLF
+ "This is an epilog and must be ignored" + CRLF
+ CRLF
+ CRLF
+ "----1242";
final List<BatchRequestPart> batchRequestParts = parse(batch);
Assert.assertNotNull(batchRequestParts);
Assert.assertEquals(2, batchRequestParts.size());
BatchRequestPart getRequestPart = batchRequestParts.get(0);
Assert.assertEquals(1, getRequestPart.getRequests().size());
ODataRequest getRequest = getRequestPart.getRequests().get(0);
Assert.assertEquals(HttpMethod.GET, getRequest.getMethod());
BatchRequestPart changeSetPart = batchRequestParts.get(1);
Assert.assertEquals(2, changeSetPart.getRequests().size());
Assert.assertEquals("iVBORw0KGgoAAAANSUhEUgAAABQAAAAMCAIAAADtbgqsAAAABmJLR0QA/wD/AP+gvaeTAAAAH0lE"
+ "QVQokWNgGHmA8S4FmpkosXngNDP+PzdANg+cZgBqiQK5mkdWWgAAAABJRU5ErkJggg==" + CRLF,
IOUtils.toString(changeSetPart.getRequests().get(0).getBody()));
Assert.assertEquals("{\"value\":5}",
IOUtils.toString(changeSetPart.getRequests().get(1).getBody()));
}