Package com.linkedin.restli.common

Source Code of com.linkedin.restli.common.TestProtocolVersionUtil

/*
   Copyright (c) 2014 LinkedIn Corp.

   Licensed 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 com.linkedin.restli.common;

import com.linkedin.r2.message.rest.RestRequestBuilder;
import com.linkedin.restli.internal.common.ProtocolVersionUtil;
import java.net.URI;
import java.net.URISyntaxException;
import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;


/**
* @author Soojung Ha
*/
public class TestProtocolVersionUtil
{
  @DataProvider(name = "headerConstant")
  public static Object[][] provideHeaderConstants()
  {
    return new Object[][]
        {
            { RestConstants.HEADER_RESTLI_PROTOCOL_VERSION },
            { RestConstants.HEADER_RESTLI_PROTOCOL_VERSION_DEPRECATED }
        };
  }

  @Test(dataProvider = "headerConstant")
  public void testExtractProtocolVersion(String headerConstant) throws URISyntaxException
  {
    ProtocolVersion p1 = new ProtocolVersion("1.2.3");
    RestRequestBuilder requestBuilder = new RestRequestBuilder(new URI("/test/1")).setHeader(headerConstant, p1.toString());
    ProtocolVersion p2 = ProtocolVersionUtil.extractProtocolVersion(requestBuilder.getHeaders());
    Assert.assertEquals(p2, p1);
  }
}
TOP

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

TOP
Copyright © 2018 www.massapi.com. 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.