Package com.linkedin.restli.common

Examples of com.linkedin.restli.common.ProtocolVersion


  @Test(dataProvider = "testForceUseNextVersionOverrideData")
  public void testForceUseNextVersionOverride(ProtocolVersionOption protocolVersionOption,
                                              ProtocolVersion expectedProtocolVersion,
                                              boolean forceUseOverrideSystemProperty)
  {
    ProtocolVersion announcedVersion = new ProtocolVersion("2.0.0");
    ProtocolVersion actualProtocolVersion = RestClient.getProtocolVersion(_BASELINE_VERSION,
                                                                          _LATEST_VERSION,
                                                                          _NEXT_VERSION,
                                                                          announcedVersion,
                                                                          protocolVersionOption,
                                                                          forceUseOverrideSystemProperty);
View Full Code Here


  }

  @SuppressWarnings("deprecation")
  private static void testUriGeneration(Request<?> request, String protocol1UriString, String protocol2UriString)
      throws URISyntaxException {
    ProtocolVersion protocol1 = AllProtocolVersions.RESTLI_PROTOCOL_1_0_0.getProtocolVersion();
    ProtocolVersion protocol2 = AllProtocolVersions.RESTLI_PROTOCOL_2_0_0.getProtocolVersion();

    URI protocol1Uri = RestliUriBuilderUtil.createUriBuilder(request, protocol1).build();
    URI protocol2Uri = RestliUriBuilderUtil.createUriBuilder(request, protocol2).build();

    Assert.assertEquals(UriComponent.decodeQuery(protocol1Uri, true),
View Full Code Here

  public <T> void sendRestRequest(final Request<T> request,
                                  RequestContext requestContext,
                                  Callback<RestResponse> callback)
  {
    RecordTemplate input = request.getInputRecord();
    ProtocolVersion protocolVersion;

    URI requestUri;
    boolean hasPrefix;

    if (request.hasUri())
View Full Code Here

    }
    Object potentialAnnouncedVersionPercentage = properties.get(RestConstants.RESTLI_PROTOCOL_VERSION_PERCENTAGE_PROPERTY);
    // if the server doesn't announce a protocol version percentage we assume it is running the announced version
    if(potentialAnnouncedVersionPercentage == null)
    {
      return new ProtocolVersion(potentialAnnouncedVersion.toString());
    }
    try
    {
      int announceVersionPercentage = Integer.parseInt(potentialAnnouncedVersionPercentage.toString());
      // if server announces percentage between 1 to 100 which is also below or equal to the generated probability, then we return announced version else the baseline
      return (announceVersionPercentage > 0 && announceVersionPercentage <= 100 && RANDOM_INSTANCE.nextInt(100) + 1 <= announceVersionPercentage) ?
          new ProtocolVersion(potentialAnnouncedVersion.toString()) : AllProtocolVersions.BASELINE_PROTOCOL_VERSION;
    }
    catch(NumberFormatException e)
    {
      // if the server announces a incorrect protocol version percentage we assume it is running the baseline version
      return AllProtocolVersions.BASELINE_PROTOCOL_VERSION;
View Full Code Here

  public String getId()
  {
    if (_entity != null && (_entity instanceof CreateResponse<?> || _entity instanceof IdResponse<?>))
    {
      final Object id = checkAndReturnId();
      final ProtocolVersion protocolVersion = ProtocolVersionUtil.extractProtocolVersion(_headers);
      return URIParamUtils.encodeKeyForHeader(id, protocolVersion);
    }
    else
    {
      return null;
View Full Code Here

  }

  @DataProvider(name = "invalidClientProtocolVersionData")
  public Object[][] provideInvalidClientProtocolVersionData()
  {
    ProtocolVersion greaterThanNext = new ProtocolVersion(AllProtocolVersions.NEXT_PROTOCOL_VERSION.getMajor() + 1,
                                                          0,
                                                          0);

    return new Object[][]
        {
            { _server, greaterThanNext, RestConstants.HEADER_RESTLI_PROTOCOL_VERSION },
            { _server, new ProtocolVersion(0, 0, 0), RestConstants.HEADER_RESTLI_PROTOCOL_VERSION },
            { _server, greaterThanNext, RestConstants.HEADER_RESTLI_PROTOCOL_VERSION_DEPRECATED },
            { _server, new ProtocolVersion(0, 0, 0), RestConstants.HEADER_RESTLI_PROTOCOL_VERSION_DEPRECATED }
        };
  }
View Full Code Here

      // if no protocol version is present we assume that the 1.0.0 protocol was used in the request.
      return AllProtocolVersions.RESTLI_PROTOCOL_1_0_0.getProtocolVersion();
    }
    else
    {
      return new ProtocolVersion(protocolVersion);
    }
  }
View Full Code Here

TOP

Related Classes of com.linkedin.restli.common.ProtocolVersion

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.