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

Java Header类代码示例

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

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



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

示例1: testLogout

import io.restassured.http.Header; //导入依赖的package包/类
@Test
public void testLogout() {
    User user = createUser();
    //@formatter:off
    Header xAuthTokenHeaderForUser = getXAuthTokenHeaderForUser(user);

    given().
        header(xAuthTokenHeaderForUser).
    when().
        post("/logout").
    then().
        statusCode(HttpStatus.SC_OK);
    //@formatter:on

    //@formatter:off
    given().
        header(xAuthTokenHeaderForUser).
    when().
        get("/token/verify").
    then().
        statusCode(HttpStatus.SC_UNAUTHORIZED);
    //@formatter:on
}
 
开发者ID:AreaFiftyLAN,项目名称:lancie-api,代码行数:24,代码来源:AuthenticationIntegrationTest.java


示例2: logHeaders

import io.restassured.http.Header; //导入依赖的package包/类
/**
 * @author wasiq.bhamla
 * @since Sep 18, 2017 8:11:09 PM
 */
private void logHeaders () {
	final LoggingSetting logging = this.setting.getLogging ();
	if (logging.isLogHeaders ()) {
		final Headers headers = this.response.headers ();
		LOG.info (LINE);
		LOG.info ("Response Headers:");
		LOG.info (LINE);
		for (final Header header : headers.asList ()) {
			LOG.info (format ("%s: %s", header.getName (), header.getValue ()));
		}
	}
}
 
开发者ID:WasiqB,项目名称:coteafs-services,代码行数:17,代码来源:ResponseHandler.java


示例3: TracksResponse

import io.restassured.http.Header; //导入依赖的package包/类
public TracksResponse(Response response) {
    this.statusCode = response.getStatusCode();

    this.responseHeaders = new HashMap<>();
    Headers headers = response.getHeaders();
    for(Header header: headers){
        responseHeaders.put(header.getName(), header.getValue());
    }

    this.body = response.body().asString();
}
 
开发者ID:eviltester,项目名称:tracksrestcasestudy,代码行数:12,代码来源:TracksResponse.java


示例4: testVerifyInvalidToken

import io.restassured.http.Header; //导入依赖的package包/类
@Test
public void testVerifyInvalidToken() {
    Header header = new Header(AUTH_HEADER, "invalid");

    //@formatter:off
    given().
        header(header).
    when().
        get("/token/verify").
    then().
        statusCode(HttpStatus.SC_UNAUTHORIZED);
    //@formatter:on
}
 
开发者ID:AreaFiftyLAN,项目名称:lancie-api,代码行数:14,代码来源:AuthenticationIntegrationTest.java


示例5: testVerifyMissingToken

import io.restassured.http.Header; //导入依赖的package包/类
@Test
public void testVerifyMissingToken() {
    Header header = new Header(AUTH_HEADER, "");

    //@formatter:off
    given().
        header(header).
    when().
        get("/token/verify").
    then().
        statusCode(HttpStatus.SC_FORBIDDEN);
    //@formatter:on
}
 
开发者ID:AreaFiftyLAN,项目名称:lancie-api,代码行数:14,代码来源:AuthenticationIntegrationTest.java


示例6: testAddMemberAsAdmin

import io.restassured.http.Header; //导入依赖的package包/类
@Test
public void testAddMemberAsAdmin() {
    User captain = createUser();
    User admin = createAdmin();
    User member = createUser();
    Team team = createTeamWithCaptain(captain);

    //@formatter:off
    Header header = getXAuthTokenHeaderForUser(admin);

    given().
        header(header).
    when().
        body(member.getEmail()).
        post(TEAM_ENDPOINT + team.getId()).
    then().
        statusCode(HttpStatus.SC_OK);

    given().
        header(header).
    when().
        get(TEAM_ENDPOINT + team.getId()).
    then().
        statusCode(HttpStatus.SC_OK).
        body("members.profile.displayName", hasItems(
                captain.getProfile().getDisplayName(),
                member.getProfile().getDisplayName())).
        body("size", equalTo(2));
    //@formatter:on
}
 
开发者ID:AreaFiftyLAN,项目名称:lancie-api,代码行数:31,代码来源:TeamRestIntegrationTest.java


示例7: testInviteMemberTwiceAsCaptain

import io.restassured.http.Header; //导入依赖的package包/类
@Test
public void testInviteMemberTwiceAsCaptain() {
    User captain = createUser();
    User user = createUser();
    Team team = createTeamWithCaptain(captain);

    //@formatter:off
    Header header = getXAuthTokenHeaderForUser(captain);

    given().
        header(header).
    when().
        body(user.getEmail()).
        post(TEAM_ENDPOINT + team.getId() + "/invites").
    then().
        statusCode(HttpStatus.SC_OK);

    given().
        header(header).
    when().
        body(user.getEmail()).
        post(TEAM_ENDPOINT + team.getId() + "/invites").
    then().
        statusCode(HttpStatus.SC_CONFLICT);
    //@formatter:on

    Collection<TeamInviteToken> tokens = teamInviteTokenRepository.findByUserEmailIgnoreCase(user.getEmail());
    Assert.assertEquals(1, tokens.size());
}
 
开发者ID:AreaFiftyLAN,项目名称:lancie-api,代码行数:30,代码来源:TeamRestIntegrationTest.java


示例8: testChangePassword

import io.restassured.http.Header; //导入依赖的package包/类
@Test
public void testChangePassword() {
    //TODO: Move to new AuthenticationTest
    User user = createUser();

    String newPassword = "newPassword";
    Map<String, String> passwordDTO = new HashMap<>();
    passwordDTO.put("oldPassword", cleartextPassword);
    passwordDTO.put("newPassword", newPassword);

    //@formatter:off
    Header xAuthTokenHeader = getXAuthTokenHeaderForUser(user);

    given().
        header(xAuthTokenHeader).
    when().
        body(passwordDTO).
        contentType(ContentType.JSON).
        post("/users/current/password").
    then().
        statusCode(HttpStatus.SC_OK);
    //@formatter:on

    removeXAuthToken(xAuthTokenHeader);

    Map<String, String> userDTO = new HashMap<>();
    userDTO.put("email", user.getEmail());
    userDTO.put("password", newPassword);

    //@formatter:off
    given().
        body(userDTO).
    when().
        post("/login").
    then().
        statusCode(HttpStatus.SC_OK).
        header("X-Auth-Token", not(isEmptyOrNullString()));
    //@formatter:on
}
 
开发者ID:AreaFiftyLAN,项目名称:lancie-api,代码行数:40,代码来源:UserRestIntegrationTest.java


示例9: testChangePasswordEmptyPassword

import io.restassured.http.Header; //导入依赖的package包/类
@Test
public void testChangePasswordEmptyPassword() {
    //TODO: Move to new AuthenticationTest
    User user = createUser();

    String newPassword = "";
    Map<String, String> passwordDTO = new HashMap<>();
    passwordDTO.put("oldPassword", cleartextPassword);
    passwordDTO.put("newPassword", newPassword);

    //@formatter:off
    Header xAuthTokenHeader = getXAuthTokenHeaderForUser(user);

    given().
        header(xAuthTokenHeader).
    when().
        body(passwordDTO).
        contentType(ContentType.JSON).
        post("/users/current/password").
    then().
        statusCode(HttpStatus.SC_BAD_REQUEST);
    //@formatter:on

    removeXAuthToken(xAuthTokenHeader);

    Map<String, String> userDTO = new HashMap<>();
    userDTO.put("email", user.getEmail());
    userDTO.put("password", cleartextPassword);

    //@formatter:off
    given().
        body(userDTO).
    when().
        post("/login").
    then().
        statusCode(HttpStatus.SC_OK).
        header("X-Auth-Token", not(isEmptyOrNullString()));
    //@formatter:on
}
 
开发者ID:AreaFiftyLAN,项目名称:lancie-api,代码行数:40,代码来源:UserRestIntegrationTest.java


示例10: cacheHeaders

import io.restassured.http.Header; //导入依赖的package包/类
private void cacheHeaders(Response response) {
    clearOldHeaders();
    Headers headers = response.getHeaders();
    for (Header header : headers) {
        String headerName = CukesOptions.HEADER_PREFIX + header.getName();
        world.put(headerName, header.getValue());
    }
}
 
开发者ID:ctco,项目名称:cukes,代码行数:9,代码来源:HttpResponseFacade.java


示例11: map

import io.restassured.http.Header; //导入依赖的package包/类
public WebAddHeader map(Header header) {
    WebAddHeader result = new WebAddHeader();
    result.setName(header.getName());
    result.setValue(header.getValue());

    return result;
}
 
开发者ID:ctco,项目名称:cukes,代码行数:8,代码来源:WebAddHeaderMapper.java


示例12: map

import io.restassured.http.Header; //导入依赖的package包/类
public WebCustomRequest map(FilterableRequestSpecification requestSpec) {
    try {
        URL url = new URL(requestSpec.getURI());
        String method = String.valueOf(requestSpec.getMethod());

        WebCustomRequest request = new WebCustomRequest();
        request.setName(method + " to " + url.toString());
        //Don't URL encode LR parameter boundaries (curly braces)
        request.setUrl(url.toString().replace("%7B", "{").replace("%7D", "}"));
        request.setMethod(method);
        request.setResource("0");
        request.setSnapshot(String.format("t%d.inf", (long) (System.currentTimeMillis() % Math.pow(10, 10))));
        request.setMode(url.getProtocol());
        request.setBody(requestSpec.getBody());

        request.getBeforeFunctions().add(new WebRequestSaveParam());
        request.getBeforeFunctions().add(new WebRequestSaveResponseBody());
        request.getBeforeFunctions().add(new WebRequestSaveResponseHeaders());

        for (Header header : requestSpec.getHeaders()) {
            request.getBeforeFunctions().add(headerMapper.map(header));
        }

        return request;
    } catch (MalformedURLException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:ctco,项目名称:cukes,代码行数:29,代码来源:WebCustomRequestMapper.java


示例13: addResponseHeaders

import io.restassured.http.Header; //导入依赖的package包/类
private void addResponseHeaders(ResponseDefinitionBuilder definition,
		Response input) {
	for (Header header : input.getHeaders().asList()) {
		String name = header.getName();
		definition.withHeader(name, input.getHeader(name));
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:8,代码来源:RequestVerifierFilter.java


示例14: getHeaders

import io.restassured.http.Header; //导入依赖的package包/类
@Override
public HttpHeaders getHeaders() {
	List<HttpHeader> headers = new ArrayList<>();
	for (Header header : request.getHeaders()) {
		String value = header.getValue();
		if ("accept".equals(header.getName().toLowerCase()) && "*/*".equals(value)) {
			continue;
		}
		headers.add(new HttpHeader(header.getName(), header.getValue()));
	}
	return new HttpHeaders(headers);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:13,代码来源:RequestVerifierFilter.java


示例15: getAllHeaderKeys

import io.restassured.http.Header; //导入依赖的package包/类
@Override
public Set<String> getAllHeaderKeys() {
	Set<String> headers = new LinkedHashSet<>();
	for (Header header : request.getHeaders()) {
		String value = header.getValue();
		if ("accept".equals(header.getName().toLowerCase()) && "*/*".equals(value)) {
			continue;
		}
		headers.add(header.getName());
	}
	return headers;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:13,代码来源:RequestVerifierFilter.java


示例16: headersToValues

import io.restassured.http.Header; //导入依赖的package包/类
protected Values headersToValues(Headers headers) {
    final Values headerValues = new Values();
    for (final Header header : headers) {
        headerValues.addValue(header.getName(), header.getValue());
    }
    return headerValues;
}
 
开发者ID:nidi3,项目名称:raml-tester,代码行数:8,代码来源:RestAssuredRamlMessage.java


示例17: map

import io.restassured.http.Header; //导入依赖的package包/类
@Override
protected Request map(FilterableRequestSpecification requestSpec) {

    Validate.isTrue(requestSpec.getMultiPartParams().isEmpty(),
            "multipart request is not supported");

    Request.RequestBuilder builder = Request.builder()
            .method(requestSpec.getMethod())
            .uri(URI.create(requestSpec.getURI()))
            .body(serialize(requestSpec.getBody()));
    for (Header header : requestSpec.getHeaders()) {
        builder.header(header.getName(), header.getValue());
    }
    return builder.build();
}
 
开发者ID:akamai,项目名称:AkamaiOPEN-edgegrid-java,代码行数:16,代码来源:RestAssuredEdgeGridRequestSigner.java


示例18: addHeader

import io.restassured.http.Header; //导入依赖的package包/类
public void addHeader(com.epam.http.annotations.Header header) {
    addHeader(header.name(), header.value());
}
 
开发者ID:epam,项目名称:JDI,代码行数:4,代码来源:RestMethod.java


示例19: addHeaders

import io.restassured.http.Header; //导入依赖的package包/类
public void addHeaders(com.epam.http.annotations.Header... headers) {
    for(com.epam.http.annotations.Header header : headers)
        addHeader(header);
}
 
开发者ID:epam,项目名称:JDI,代码行数:5,代码来源:RestMethod.java


示例20: getXAuthTokenHeaderForUser

import io.restassured.http.Header; //导入依赖的package包/类
protected Header getXAuthTokenHeaderForUser(User user) {
    return getXAuthTokenHeaderForUser(user.getEmail());
}
 
开发者ID:AreaFiftyLAN,项目名称:lancie-api,代码行数:4,代码来源:XAuthIntegrationTest.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java UpdateByPrimaryKeyWithoutBLOBsElementGenerator类代码示例发布时间:2022-05-22
下一篇:
Java Messages类代码示例发布时间: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