Java Code Examples for org.apache.olingo.commons.api.format.ContentType#JSON

The following examples show how to use org.apache.olingo.commons.api.format.ContentType#JSON . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ContentNegotiator.java    From olingo-odata4 with Apache License 2.0 5 votes vote down vote up
private static ContentType mapContentType(final String formatString, 
    RepresentationType representationType) {
  if (representationType.name().equals(METADATA)) {
    return JSON.equalsIgnoreCase(formatString) ||
        APPLICATION_JSON.equalsIgnoreCase(formatString) ? ContentType.APPLICATION_JSON :
      XML.equalsIgnoreCase(formatString) ? ContentType.APPLICATION_XML :
        ATOM.equalsIgnoreCase(formatString) ? ContentType.APPLICATION_ATOM_XML : null;
  } else {
    return JSON.equalsIgnoreCase(formatString) ? ContentType.JSON :
        XML.equalsIgnoreCase(formatString) ? ContentType.APPLICATION_XML :
            ATOM.equalsIgnoreCase(formatString) ? ContentType.APPLICATION_ATOM_XML : 
              APPLICATION_JSON.equalsIgnoreCase(formatString)? ContentType.APPLICATION_JSON: null;
  }
}
 
Example 2
Source File: JSONTest.java    From olingo-odata4 with Apache License 2.0 5 votes vote down vote up
protected void entitySetInServerMode(final String filename, final ContentType contentType) throws Exception {
  final StringWriter writer = new StringWriter();
  if (contentType == ContentType.JSON) {
    new JsonSerializer(true, contentType).write(writer, client.getDeserializer(contentType).toEntitySet(
        getClass().getResourceAsStream(filename + "." + getSuffix(contentType))));
  } else {
    client.getSerializer(contentType).write(writer, client.getDeserializer(contentType).toEntitySet(
        getClass().getResourceAsStream(filename + "." + getSuffix(contentType))).getPayload());
  }
  assertSimilar(filename + "." + getSuffix(contentType), writer.toString(), true);
}
 
Example 3
Source File: JSONTest.java    From olingo-odata4 with Apache License 2.0 5 votes vote down vote up
protected void entityInServerMode(final String filename, final ContentType contentType) throws Exception {
  final StringWriter writer = new StringWriter();
  if (contentType == ContentType.JSON) {
    new JsonSerializer(true, contentType).write(writer, client.getDeserializer(contentType).toEntity(
        getClass().getResourceAsStream(filename + "." + getSuffix(contentType))));
  } else {
    client.getSerializer(contentType).write(writer, client.getDeserializer(contentType).toEntity(
        getClass().getResourceAsStream(filename + "." + getSuffix(contentType))).getPayload());
  }
  assertSimilar(filename + "." + getSuffix(contentType), writer.toString(), true);
}
 
Example 4
Source File: JSONTest.java    From olingo-odata4 with Apache License 2.0 5 votes vote down vote up
protected void propertyInServerMode(final String filename, final ContentType contentType) throws Exception {
  final StringWriter writer = new StringWriter();
  if (contentType == ContentType.JSON) {
    new JsonSerializer(true, contentType).write(writer, client.getDeserializer(contentType).
        toProperty(getClass().getResourceAsStream(filename + "." + getSuffix(contentType))));
  } else {
    client.getSerializer(contentType).write(writer, client.getDeserializer(contentType).
        toProperty(getClass().getResourceAsStream(filename + "." + getSuffix(contentType))).getPayload());
  }

  assertSimilar(filename + "." + getSuffix(contentType), writer.toString(), true);
}
 
Example 5
Source File: JSONTest.java    From olingo-odata4 with Apache License 2.0 4 votes vote down vote up
protected ContentType getODataPubFormat() {
  return ContentType.JSON;
}
 
Example 6
Source File: JSONTest.java    From olingo-odata4 with Apache License 2.0 4 votes vote down vote up
protected ContentType getODataFormat() {
  return ContentType.JSON;
}