• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java HttpMethod类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.olingo.commons.api.http.HttpMethod的典型用法代码示例。如果您正苦于以下问题:Java HttpMethod类的具体用法?Java HttpMethod怎么用?Java HttpMethod使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



HttpMethod类属于org.apache.olingo.commons.api.http包,在下文中一共展示了HttpMethod类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: updateEntity

import org.apache.olingo.commons.api.http.HttpMethod; //导入依赖的package包/类
public static void updateEntity(RdfEdmProvider rdfEdmProvider, UriInfo uriInfo, Entity requestEntity,
		HttpMethod httpMethod) throws OData2SparqlException {
	SparqlStatement sparqlStatement = null;
	// 1. Retrieve the entity set which belongs to the requested entity
	List<UriResource> resourcePaths = uriInfo.getUriResourceParts();
	// Note: only in our example we can assume that the first segment is the EntitySet
	UriResourceEntitySet uriResourceEntitySet = (UriResourceEntitySet) resourcePaths.get(0);
	EdmEntitySet edmEntitySet = uriResourceEntitySet.getEntitySet();
	//EdmEntityType edmEntityType = edmEntitySet.getEntityType();

	RdfEntityType entityType = rdfEdmProvider.getRdfEntityTypefromEdmEntitySet(edmEntitySet);

	List<UriParameter> keyPredicates = uriResourceEntitySet.getKeyPredicates();
	// Note that this updateEntity()-method is invoked for both PUT or PATCH operations  
	SparqlCreateUpdateDeleteBuilder sparqlCreateUpdateDeleteBuilder = new SparqlCreateUpdateDeleteBuilder(
			rdfEdmProvider);
	try {
		sparqlStatement = sparqlCreateUpdateDeleteBuilder.generateUpdateEntity(entityType, keyPredicates,
				requestEntity);
	} catch (Exception e) {
		log.error(e.getMessage());
		throw new OData2SparqlException(e.getMessage());
	}
	sparqlStatement.executeDelete(rdfEdmProvider);
}
 
开发者ID:peterjohnlawrence,项目名称:com.inova8.odata2sparql.v4,代码行数:26,代码来源:SparqlBaseCommand.java


示例2: queryESCompCollDerivedJson

import org.apache.olingo.commons.api.http.HttpMethod; //导入依赖的package包/类
@Test
public void queryESCompCollDerivedJson() throws Exception {
  URL url = new URL(SERVICE_URI + "ESCompCollDerived?$format=json");

  HttpURLConnection connection = (HttpURLConnection) url.openConnection();
  connection.setRequestMethod(HttpMethod.GET.name());
  connection.connect();

  assertEquals(HttpStatusCode.OK.getStatusCode(), connection.getResponseCode());
  assertEquals(ContentType.JSON, ContentType.create(connection.getHeaderField(HttpHeader.CONTENT_TYPE)));

  final String content = IOUtils.toString(connection.getInputStream());

  assertTrue(content.contains(
      "[{\"PropertyInt16\":32767,\"PropertyCompAno\":null,\"CollPropertyCompAno\":[{\"PropertyString\":" +
      "\"TEST9876\"}]},{\"PropertyInt16\":12345,\"PropertyCompAno\":{\"@odata.type\":" +
      "\"#olingo.odata.test1.CTBaseAno\",\"PropertyString\":\"Num111\",\"AdditionalPropString\":" +
      "\"Test123\"},\"CollPropertyCompAno\":[{\"@odata.type\":\"#olingo.odata.test1.CTBaseAno\"," +
      "\"PropertyString\":\"TEST12345\",\"AdditionalPropString\":\"Additional12345\"}," +
      "{\"PropertyString\":\"TESTabcd\"}]}]}" ));
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:22,代码来源:DerivedAndMixedTypeTestITCase.java


示例3: queryESAllPrimDerivedXml

import org.apache.olingo.commons.api.http.HttpMethod; //导入依赖的package包/类
@Test
public void queryESAllPrimDerivedXml() throws Exception {
  URL url = new URL(SERVICE_URI + "ESAllPrimDerived(0)?$expand=NavPropertyETTwoPrimMany&$format=xml");

  HttpURLConnection connection = (HttpURLConnection) url.openConnection();
  connection.setRequestMethod(HttpMethod.GET.name());
  connection.connect();

  assertEquals(HttpStatusCode.OK.getStatusCode(), connection.getResponseCode());

  final String content = IOUtils.toString(connection.getInputStream());
  assertTrue(content.contains("term=\"#olingo.odata.test1.ETBase\"/>"));
  assertTrue(content.contains(
      "<d:PropertyInt16 m:type=\"Int16\">32766</d:PropertyInt16>" +
      "<d:PropertyString>Test String1</d:PropertyString>" +
      "<d:AdditionalPropertyString_5>Additional String1</d:AdditionalPropertyString_5>"));
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:18,代码来源:DerivedAndMixedTypeTestITCase.java


示例4: queryESCompCollDerivedJsonNone

import org.apache.olingo.commons.api.http.HttpMethod; //导入依赖的package包/类
@Test
public void queryESCompCollDerivedJsonNone() throws Exception {
  URL url = new URL(SERVICE_URI + "ESCompCollDerived");

  HttpURLConnection connection = (HttpURLConnection) url.openConnection();
  connection.setRequestMethod(HttpMethod.GET.name());
  connection.setRequestProperty(HttpHeader.ACCEPT, "application/json;odata.metadata=none");
  connection.connect();

  assertEquals(HttpStatusCode.OK.getStatusCode(), connection.getResponseCode());
  assertEquals(ContentType.JSON_NO_METADATA, ContentType.create(connection.getHeaderField(HttpHeader.CONTENT_TYPE)));

  final String content = IOUtils.toString(connection.getInputStream());

  assertTrue(content.contains(
      "[{\"PropertyInt16\":32767,\"PropertyCompAno\":null,\"CollPropertyCompAno\":[{\"PropertyString\":" +
      "\"TEST9876\"}]},{\"PropertyInt16\":12345,\"PropertyCompAno\":{"+
      "\"PropertyString\":\"Num111\",\"AdditionalPropString\":" +
      "\"Test123\"},\"CollPropertyCompAno\":[{" +
      "\"PropertyString\":\"TEST12345\",\"AdditionalPropString\":\"Additional12345\"}," +
      "{\"PropertyString\":\"TESTabcd\"}]}]}" ));
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:23,代码来源:DerivedAndMixedTypeTestITCase.java


示例5: queryESTwoPrimWithEntityTypeCast

import org.apache.olingo.commons.api.http.HttpMethod; //导入依赖的package包/类
@Test
public void queryESTwoPrimWithEntityTypeCast() throws Exception {
  URL url = new URL(SERVICE_URI + "ESTwoPrim(111)/olingo.odata.test1.ETBase");

  HttpURLConnection connection = (HttpURLConnection) url.openConnection();
  connection.setRequestMethod(HttpMethod.GET.name());
  connection.setRequestProperty(HttpHeader.ACCEPT, "application/json;odata.metadata=full");
  connection.connect();

  assertEquals(HttpStatusCode.OK.getStatusCode(), connection.getResponseCode());
  assertEquals(ContentType.JSON_FULL_METADATA, 
      ContentType.create(connection.getHeaderField(HttpHeader.CONTENT_TYPE)));

  final String content = IOUtils.toString(connection.getInputStream());
  assertTrue(content.contains("\"@odata.type\":\"#olingo.odata.test1.ETBase\","
      + "\"@odata.id\":\"ESBase(111)\","
      + "\"[email protected]\":\"#Int16\","
      + "\"PropertyInt16\":111,"
      + "\"PropertyString\":\"TEST A\","
      + "\"AdditionalPropertyString_5\":\"TEST A 0815\""));
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:22,代码来源:DerivedAndMixedTypeTestITCase.java


示例6: streamESStreamJson

import org.apache.olingo.commons.api.http.HttpMethod; //导入依赖的package包/类
@Test
public void streamESStreamJson() throws Exception {
  URL url = new URL(SERVICE_URI + "ESStream?$format=json");

  HttpURLConnection connection = (HttpURLConnection) url.openConnection();
  connection.setRequestMethod(HttpMethod.GET.name());
  connection.connect();

  assertEquals(HttpStatusCode.OK.getStatusCode(), connection.getResponseCode());
  assertEquals(ContentType.JSON, ContentType.create(connection.getHeaderField(HttpHeader.CONTENT_TYPE)));

  final String content = IOUtils.toString(connection.getInputStream());

  assertTrue(content.contains("[email protected]\"," +
          "\"[email protected]\"," +
          "\"[email protected]\""));
  assertTrue(content.contains("\"PropertyString\":\"TEST 1->streamed\""));
  assertTrue(content.contains("\"PropertyString\":\"TEST 2->streamed\""));
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:20,代码来源:BasicStreamITCase.java


示例7: validatePropertyOperations

import org.apache.olingo.commons.api.http.HttpMethod; //导入依赖的package包/类
private void validatePropertyOperations(final UriInfo uriInfo, final HttpMethod method)
    throws UriValidationException {
  final List<UriResource> parts = uriInfo.getUriResourceParts();
  final UriResource last = !parts.isEmpty() ? parts.get(parts.size() - 1) : null;
  final UriResource previous = parts.size() > 1 ? parts.get(parts.size() - 2) : null;
  if (last != null
      && (last.getKind() == UriResourceKind.primitiveProperty
      || last.getKind() == UriResourceKind.complexProperty
      || (last.getKind() == UriResourceKind.value
          && previous != null && previous.getKind() == UriResourceKind.primitiveProperty))) {
    final EdmProperty property = ((UriResourceProperty)
        (last.getKind() == UriResourceKind.value ? previous : last)).getProperty();
    if (method == HttpMethod.PATCH && property.isCollection()) {
      throw new UriValidationException("Attempt to patch collection property.",
          UriValidationException.MessageKeys.UNSUPPORTED_HTTP_METHOD, method.toString());
    }
    if (method == HttpMethod.DELETE && !property.isNullable()) {
      throw new UriValidationException("Attempt to delete non-nullable property.",
          UriValidationException.MessageKeys.UNSUPPORTED_HTTP_METHOD, method.toString());
    }
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:23,代码来源:UriValidator.java


示例8: streamESStreamServerSidePagingNextXml

import org.apache.olingo.commons.api.http.HttpMethod; //导入依赖的package包/类
@Test
public void streamESStreamServerSidePagingNextXml() throws Exception {
  URL url = new URL(SERVICE_URI + "ESStreamServerSidePaging?$format=xml&$skiptoken=1%2A10");

  HttpURLConnection connection = (HttpURLConnection) url.openConnection();
  connection.setRequestMethod(HttpMethod.GET.name());
  connection.connect();

  assertEquals(HttpStatusCode.OK.getStatusCode(), connection.getResponseCode());
  assertEquals(ContentType.APPLICATION_XML, ContentType.create(connection.getHeaderField(HttpHeader.CONTENT_TYPE)));

  final String content = IOUtils.toString(connection.getInputStream());
  assertTrue(content.contains("<a:link rel=\"next\" href="));
  assertTrue(content.contains("ESStreamServerSidePaging?$format=xml&amp;%24skiptoken=2%2A10\"/>"));
  assertTrue(content.contains("<a:id>ESStreamServerSidePaging(11)</a:id>"));
  assertTrue(content.contains("<d:PropertyInt16 m:type=\"Int16\">11</d:PropertyInt16>"));
  assertTrue(content.contains("<d:PropertyStream m:type=\"Stream\">readLink</d:PropertyStream>"));
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:19,代码来源:BasicStreamITCase.java


示例9: streamESStreamServerSidePagingJsonNext

import org.apache.olingo.commons.api.http.HttpMethod; //导入依赖的package包/类
@Test
public void streamESStreamServerSidePagingJsonNext() throws Exception {
  URL url = new URL(SERVICE_URI + "ESStreamServerSidePaging?$format=json&$skiptoken=1%2A10");

  HttpURLConnection connection = (HttpURLConnection) url.openConnection();
  connection.setRequestMethod(HttpMethod.GET.name());
  connection.connect();

  assertEquals(HttpStatusCode.OK.getStatusCode(), connection.getResponseCode());
  assertEquals(ContentType.JSON, ContentType.create(connection.getHeaderField(HttpHeader.CONTENT_TYPE)));

  final String content = IOUtils.toString(connection.getInputStream());

  assertTrue(content.contains("{\"PropertyInt16\":12,"+
  "\"[email protected]\":\"eTag\",\"[email protected]\":\"image/jpeg\"}"));
  assertTrue(content.contains("\"@odata.nextLink\""));
  assertTrue(content.contains("ESStreamServerSidePaging?$format=json&%24skiptoken=2%2A10"));
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:19,代码来源:BasicStreamITCase.java


示例10: streamCountFalsetXml

import org.apache.olingo.commons.api.http.HttpMethod; //导入依赖的package包/类
@Test
public void streamCountFalsetXml() throws Exception {
  URL url = new URL(SERVICE_URI + "ESStreamServerSidePaging?$count=false&$format=xml");

  HttpURLConnection connection = (HttpURLConnection) url.openConnection();
  connection.setRequestMethod(HttpMethod.GET.name());
  connection.connect();

  assertEquals(HttpStatusCode.OK.getStatusCode(), connection.getResponseCode());
  assertEquals(ContentType.APPLICATION_XML, ContentType.create(connection.getHeaderField(HttpHeader.CONTENT_TYPE)));

  final String content = IOUtils.toString(connection.getInputStream());
  assertTrue(content.contains("<a:link rel=\"next\" href="));
  assertTrue(content.contains("ESStreamServerSidePaging?$count=false&amp;$format=xml&amp;%24skiptoken=1%2A10\"/>"));
  assertTrue(content.contains("<a:id>ESStreamServerSidePaging(1)</a:id>"));
  assertTrue(content.contains("<d:PropertyInt16 m:type=\"Int16\">1</d:PropertyInt16>"));
  assertTrue(content.contains("<d:PropertyStream m:type=\"Stream\">readLink</d:PropertyStream>"));
  assertFalse(content.contains("<m:count>504</m:count>"));
  }
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:20,代码来源:BasicStreamITCase.java


示例11: streamCountFalseJson

import org.apache.olingo.commons.api.http.HttpMethod; //导入依赖的package包/类
@Test
public void streamCountFalseJson() throws Exception {
  URL url = new URL(SERVICE_URI + "ESStreamServerSidePaging?$count=false&$format=json");

  HttpURLConnection connection = (HttpURLConnection) url.openConnection();
  connection.setRequestMethod(HttpMethod.GET.name());
  connection.connect();

  assertEquals(HttpStatusCode.OK.getStatusCode(), connection.getResponseCode());
  assertEquals(ContentType.JSON, ContentType.create(connection.getHeaderField(HttpHeader.CONTENT_TYPE)));

  final String content = IOUtils.toString(connection.getInputStream());

  assertTrue(content.contains("{\"PropertyInt16\":2,"+
  "\"Pr[email protected]\":\"eTag\",\"[email protected]\":\"image/jpeg\"}"));
  assertTrue(content.contains("\"@odata.nextLink\""));
  assertTrue(content.contains("ESStreamServerSidePaging?$count=false&$format=json&%24skiptoken=1%2A10"));
  assertFalse(content.contains("\"@odata.count\":504"));
  }
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:20,代码来源:BasicStreamITCase.java


示例12: updateEntity

import org.apache.olingo.commons.api.http.HttpMethod; //导入依赖的package包/类
public void updateEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo,
                          ContentType requestFormat, ContentType responseFormat)
						throws ODataApplicationException, DeserializerException, SerializerException {
	
	// 1. Retrieve the entity set which belongs to the requested entity 
	List<UriResource> resourcePaths = uriInfo.getUriResourceParts();
	// Note: only in our example we can assume that the first segment is the EntitySet
	UriResourceEntitySet uriResourceEntitySet = (UriResourceEntitySet) resourcePaths.get(0); 
	EdmEntitySet edmEntitySet = uriResourceEntitySet.getEntitySet();
	EdmEntityType edmEntityType = edmEntitySet.getEntityType();

	// 2. update the data in backend
	// 2.1. retrieve the payload from the PUT request for the entity to be updated 
	InputStream requestInputStream = request.getBody();
	ODataDeserializer deserializer = odata.createDeserializer(requestFormat);
	DeserializerResult result = deserializer.entity(requestInputStream, edmEntityType);
	Entity requestEntity = result.getEntity();
	// 2.2 do the modification in backend
	List<UriParameter> keyPredicates = uriResourceEntitySet.getKeyPredicates();
	// Note that this updateEntity()-method is invoked for both PUT or PATCH operations
	HttpMethod httpMethod = request.getMethod();
	storage.updateEntityData(edmEntitySet, keyPredicates, requestEntity, httpMethod);
	
	//3. configure the response object
	response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode());
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:27,代码来源:DemoEntityProcessor.java


示例13: dispatchComplexProperty

import org.apache.olingo.commons.api.http.HttpMethod; //导入依赖的package包/类
@Test
public void dispatchComplexProperty() throws Exception {
  final String uri = "ESMixPrimCollComp(7)/PropertyComp";
  final ComplexProcessor processor = mock(ComplexProcessor.class);

  dispatch(HttpMethod.GET, uri, processor);
  verify(processor).readComplex(
      any(ODataRequest.class), any(ODataResponse.class), any(UriInfo.class), any(ContentType.class));

  dispatch(HttpMethod.PATCH, uri, processor);
  verify(processor).updateComplex(
      any(ODataRequest.class), any(ODataResponse.class), any(UriInfo.class), any(ContentType.class),
      any(ContentType.class));

  dispatch(HttpMethod.PUT, uri, processor);
  verify(processor, times(2)).updateComplex(
      any(ODataRequest.class), any(ODataResponse.class), any(UriInfo.class), any(ContentType.class),
      any(ContentType.class));

  dispatch(HttpMethod.DELETE, uri, processor);
  verify(processor).deleteComplex(any(ODataRequest.class), any(ODataResponse.class), any(UriInfo.class));

  dispatchMethodNotAllowed(HttpMethod.POST, uri, processor);
  dispatchMethodNotAllowed(HttpMethod.HEAD, uri, processor);
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:26,代码来源:ODataHandlerImplTest.java


示例14: getEntityUpdateRequest

import org.apache.olingo.commons.api.http.HttpMethod; //导入依赖的package包/类
@Override
public <E extends ClientEntity> ODataEntityUpdateRequest<E> getEntityUpdateRequest(
    final UpdateType type, final E entity) {

  if (entity.getEditLink() == null) {
    throw new IllegalArgumentException("No edit link found");
  }

  final ODataEntityUpdateRequest<E> req;

  if (client.getConfiguration().isUseXHTTPMethod()) {
    req = new ODataEntityUpdateRequestImpl<E>(client, HttpMethod.POST, entity.getEditLink(), entity);
    req.setXHTTPMethod(type.getMethod().name());
  } else {
    req = new ODataEntityUpdateRequestImpl<E>(client, type.getMethod(), entity.getEditLink(), entity);
  }

  return req;
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:20,代码来源:CUDRequestFactoryImpl.java


示例15: getPropertyComplexValueUpdateRequest

import org.apache.olingo.commons.api.http.HttpMethod; //导入依赖的package包/类
@Override
public ODataPropertyUpdateRequest getPropertyComplexValueUpdateRequest(
    final URI targetURI, final UpdateType type, final ClientProperty property) {

  if (!property.hasComplexValue()) {
    throw new IllegalArgumentException("A complex value is required");
  }

  final ODataPropertyUpdateRequest req;

  if (client.getConfiguration().isUseXHTTPMethod()) {
    req = new ODataPropertyUpdateRequestImpl(client, HttpMethod.POST, targetURI, property);
    req.setXHTTPMethod(type.getMethod().name());
  } else {
    req = new ODataPropertyUpdateRequestImpl(client, type.getMethod(), targetURI, property);
  }

  return req;
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:20,代码来源:CUDRequestFactoryImpl.java


示例16: dispatchPrimitiveProperty

import org.apache.olingo.commons.api.http.HttpMethod; //导入依赖的package包/类
@Test
public void dispatchPrimitiveProperty() throws Exception {
  final String uri = "ESAllPrim(0)/PropertyString";
  final PrimitiveProcessor processor = mock(PrimitiveProcessor.class);

  dispatch(HttpMethod.GET, uri, processor);
  verify(processor).readPrimitive(
      any(ODataRequest.class), any(ODataResponse.class), any(UriInfo.class), any(ContentType.class));

  dispatch(HttpMethod.PATCH, uri, processor);
  verify(processor).updatePrimitive(
      any(ODataRequest.class), any(ODataResponse.class), any(UriInfo.class), any(ContentType.class),
      any(ContentType.class));

  dispatch(HttpMethod.PUT, uri, processor);
  verify(processor, times(2)).updatePrimitive(
      any(ODataRequest.class), any(ODataResponse.class), any(UriInfo.class), any(ContentType.class),
      any(ContentType.class));

  dispatch(HttpMethod.DELETE, uri, processor);
  verify(processor).deletePrimitive(any(ODataRequest.class), any(ODataResponse.class), any(UriInfo.class));

  dispatchMethodNotAllowed(HttpMethod.POST, uri, processor);
  dispatchMethodNotAllowed(HttpMethod.HEAD, uri, processor);
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:26,代码来源:ODataHandlerImplTest.java


示例17: getODataPath

import org.apache.olingo.commons.api.http.HttpMethod; //导入依赖的package包/类
private String getODataPath(final ODataRequest request, final ODataResponse response)
    throws BatchDeserializerException {
  String resourceUri = null;

  if (request.getMethod() == HttpMethod.POST) {
    // Create entity
    // The URI of the new resource will be generated by the server and published in the location header
    final String locationHeader = response.getHeader(HttpHeader.LOCATION);
    resourceUri = locationHeader == null ? null : parseODataPath(locationHeader, request.getRawBaseUri());
  } else {
    // Update, Upsert (PUT, PATCH, Delete)
    // These methods still addresses a given resource, so we use the URI given by the request
    resourceUri = request.getRawODataPath();
  }

  return resourceUri;
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:18,代码来源:BatchReferenceRewriter.java


示例18: dispatchSingletonMedia

import org.apache.olingo.commons.api.http.HttpMethod; //导入依赖的package包/类
@Test
public void dispatchSingletonMedia() throws Exception {
  final String uri = "SIMedia/$value";
  final MediaEntityProcessor processor = mock(MediaEntityProcessor.class);
  
  dispatch(HttpMethod.GET, uri, processor);
  verify(processor).readMediaEntity(
      any(ODataRequest.class), any(ODataResponse.class), any(UriInfo.class), any(ContentType.class));

  dispatch(HttpMethod.PUT, uri, processor);
  verify(processor).updateMediaEntity(
      any(ODataRequest.class), any(ODataResponse.class), any(UriInfo.class), any(ContentType.class),
      any(ContentType.class));

  dispatchMethodNotAllowed(HttpMethod.PATCH, uri, processor);
  dispatchMethodNotAllowed(HttpMethod.POST, uri, processor);
  dispatchMethodNotAllowed(HttpMethod.DELETE, uri, processor);
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:19,代码来源:ODataHandlerImplTest.java


示例19: testIEEE754ParameterViaAcceptHeader

import org.apache.olingo.commons.api.http.HttpMethod; //导入依赖的package包/类
@Test
public void testIEEE754ParameterViaAcceptHeader() throws Exception {
  final URL url = new URL(SERVICE_URI + "ESAllPrim(32767)");
  final HttpURLConnection connection = (HttpURLConnection) url.openConnection();
  connection.setRequestMethod(HttpMethod.GET.name());
  connection.setRequestProperty(HttpHeader.ACCEPT, "application/json;IEEE754Compatible=true");
  connection.connect();

  assertEquals(HttpStatusCode.OK.getStatusCode(), connection.getResponseCode());
  assertEquals(ContentType.create(ContentType.JSON, ContentType.PARAMETER_IEEE754_COMPATIBLE, "true"),
      ContentType.create(connection.getContentType()));
  final String content = IOUtils.toString(connection.getInputStream());

  assertTrue(content.contains("\"PropertyDecimal\":\"34\""));
  assertTrue(content.contains("\"PropertyInt64\":\"9223372036854775807\""));
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:17,代码来源:BasicHttpITCase.java


示例20: contentTypeCaseInsensitive

import org.apache.olingo.commons.api.http.HttpMethod; //导入依赖的package包/类
@Test
public void contentTypeCaseInsensitive() throws Exception {
  final String batch = "--" + BOUNDARY + CRLF
      + HttpHeader.CONTENT_TYPE + ": " + MULTIPART_MIXED + "; boundary=" + CHANGESET_BOUNDARY + CRLF
      + CRLF
      + "--" + CHANGESET_BOUNDARY + CRLF
      + MIME_HEADERS
      + HttpHeader.CONTENT_ID + ": 1" + CRLF
      + HttpHeader.CONTENT_LENGTH + ": 200" + CRLF
      + CRLF
      + HttpMethod.PATCH + " ESAllPrim(32767)" + HTTP_VERSION + CRLF
      + HttpHeader.CONTENT_TYPE + ": " + APPLICATION_JSON + CRLF
      + CRLF
      + "{\"PropertyString\":\"new\"}" + CRLF
      + "--" + CHANGESET_BOUNDARY + "--" + CRLF
      + CRLF
      + "--" + BOUNDARY + "--";

  parse(batch);
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:21,代码来源:BatchRequestParserTest.java



注:本文中的org.apache.olingo.commons.api.http.HttpMethod类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java RelationTypeNotFoundException类代码示例发布时间:2022-05-22
下一篇:
Java Presence类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap