本文整理汇总了Java中com.jayway.restassured.response.Header类的典型用法代码示例。如果您正苦于以下问题:Java Header类的具体用法?Java Header怎么用?Java Header使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Header类属于com.jayway.restassured.response包,在下文中一共展示了Header类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testNonStandardUnitsPrometheus
import com.jayway.restassured.response.Header; //导入依赖的package包/类
@Test
@RunAsClient
@InSequence(30)
public void testNonStandardUnitsPrometheus() {
String prefix = "jellybean_histogram_";
Header wantPrometheusFormat = new Header("Accept", TEXT_PLAIN);
given().header(wantPrometheusFormat).get("/metrics/application/jellybeanHistogram").then().statusCode(200)
.and()
.body(containsString(prefix + "jellybeans_count"))
.body(containsString("# TYPE application:" + prefix + "jellybeans summary"))
.body(containsString(prefix + "mean_jellybeans"))
.body(containsString(prefix + "min_jellybeans"))
.body(containsString(prefix + "max_jellybeans"))
.body(containsString(prefix + "stddev_jellybeans"))
.body(containsString(prefix + "jellybeans{tier=\"integration\",quantile=\"0.5\"}"))
.body(containsString(prefix + "jellybeans{tier=\"integration\",quantile=\"0.75\"}"))
.body(containsString(prefix + "jellybeans{tier=\"integration\",quantile=\"0.95\"}"))
.body(containsString(prefix + "jellybeans{tier=\"integration\",quantile=\"0.98\"}"))
.body(containsString(prefix + "jellybeans{tier=\"integration\",quantile=\"0.99\"}"))
.body(containsString(prefix + "jellybeans{tier=\"integration\",quantile=\"0.999\"}"));
}
示例2: testOptionalBaseMetrics
import com.jayway.restassured.response.Header; //导入依赖的package包/类
@Test
@RunAsClient
@InSequence(31)
public void testOptionalBaseMetrics() {
Header wantJson = new Header("Accept", APPLICATION_JSON);
JsonPath jsonPath = given().header(wantJson).options("/metrics/base").jsonPath();
Map<String, Object> elements = jsonPath.getMap(".");
Map<String, MiniMeta> names = getExpectedMetadataFromXmlFile(MetricRegistry.Type.BASE);
for (String item : names.keySet()) {
if (elements.containsKey(item) && names.get(item).optional) {
String prefix = names.get(item).name;
String type = "\""+prefix+"\""+".type";
String unit= "\""+prefix+"\""+".unit";
given().header(wantJson).options("/metrics/base/"+prefix).then().statusCode(200)
.body(type, equalTo(names.get(item).type))
.body(unit, equalTo(names.get(item).unit));
}
}
}
示例3: buildResponse
import com.jayway.restassured.response.Header; //导入依赖的package包/类
private Response buildResponse() {
ResponseBuilder rspBuilder = new ResponseBuilder();
rspBuilder.setStatusCode(200);
rspBuilder.setBody("{\"field_path\":\"field_value\",\"array1\":[{\"array_field1\":\"array_field_value1\"}]}");
List<Header> headerList = new ArrayList<>();
Header header1 = new Header("test_header", "test_value");
Header header2 = new Header("test_header2", "test_value2");
headerList.add(header1);
headerList.add(header2);
Headers headers = new Headers(headerList);
rspBuilder.setHeaders(headers);
List<Cookie> cookieList = new ArrayList<>();
Cookie cookie1 = new Cookie.Builder("test_cookie", "test_value").build();
Cookie cookie2 = new Cookie.Builder("test_cookie2", "test_value2").build();
cookieList.add(cookie1);
cookieList.add(cookie2);
Cookies cookies = new Cookies(cookieList);
rspBuilder.setCookies(cookies);
return rspBuilder.build();
}
示例4: whenAcceptEncodingGzipReceiveCompressedStream
import com.jayway.restassured.response.Header; //导入依赖的package包/类
@Test(timeout = 10000)
public void whenAcceptEncodingGzipReceiveCompressedStream()
throws ExecutionException, InterruptedException {
// ARRANGE //
// push events to one of the partitions
final int eventsPushed = 2;
kafkaHelper.writeMultipleMessageToPartition(TEST_PARTITION, topicName, DUMMY_EVENT, eventsPushed);
// ACT //
final Response response = given()
.header(new Header("X-nakadi-cursors", xNakadiCursors))
.header(new Header("Accept-Encoding", "gzip"))
.param("batch_limit", "5")
.param("stream_timeout", "2")
.param("batch_flush_timeout", "2")
.when()
.get(streamEndpoint);
// ASSERT //
response.then().statusCode(HttpStatus.OK.value()).header(HttpHeaders.TRANSFER_ENCODING, "chunked");
response.then().header("Content-Encoding", "gzip");
}
示例5: whenReadEventsConsumerIsBlocked
import com.jayway.restassured.response.Header; //导入依赖的package包/类
@Test(timeout = 10000)
public void whenReadEventsConsumerIsBlocked() throws Exception {
// blocking streaming client after 3 seconds
new Thread(() -> {
try {
Thread.sleep(3000);
SettingsControllerAT.blacklist(eventType.getName(), BlacklistService.Type.CONSUMER_ET);
} catch (final Exception e) {
e.printStackTrace();
}
}).start();
try {
// read events from the stream until we are blocked otherwise TestTimedOutException will be thrown and test
// is considered to be failed
given()
.header(new Header("X-nakadi-cursors", xNakadiCursors))
.param("batch_limit", "1")
.param("stream_timeout", "60")
.param("batch_flush_timeout", "10")
.when()
.get(streamEndpoint);
} finally {
SettingsControllerAT.whitelist(eventType.getName(), BlacklistService.Type.CONSUMER_ET);
}
}
示例6: testApplicationJsonResponseContentType
import com.jayway.restassured.response.Header; //导入依赖的package包/类
@Test
@RunAsClient
@InSequence(1)
public void testApplicationJsonResponseContentType() {
Header acceptHeader = new Header("Accept", APPLICATION_JSON);
given().header(acceptHeader).when().get("/metrics").then().statusCode(200).and().contentType(APPLICATION_JSON);
}
示例7: testTextPlainResponseContentType
import com.jayway.restassured.response.Header; //导入依赖的package包/类
@Test
@RunAsClient
@InSequence(2)
public void testTextPlainResponseContentType() {
Header acceptHeader = new Header("Accept", TEXT_PLAIN);
given().header(acceptHeader).when().get("/metrics").then().statusCode(200).and().contentType(TEXT_PLAIN);
}
示例8: testBaseAttributeJson
import com.jayway.restassured.response.Header; //导入依赖的package包/类
@Test
@RunAsClient
@InSequence(7)
public void testBaseAttributeJson() {
Header wantJson = new Header("Accept", APPLICATION_JSON);
given().header(wantJson).when().get("/metrics/base/thread.max.count").then().statusCode(200).and()
.contentType(MpMetricTest.APPLICATION_JSON).and().body(containsString("thread.max.count"));
}
示例9: testBaseMetadata
import com.jayway.restassured.response.Header; //导入依赖的package包/类
@Test
@RunAsClient
@InSequence(10)
public void testBaseMetadata() {
Header wantJson = new Header("Accept", APPLICATION_JSON);
given().header(wantJson).options("/metrics/base").then().statusCode(200).and()
.contentType(MpMetricTest.APPLICATION_JSON);
}
示例10: testBaseMetadataTypeAndUnit
import com.jayway.restassured.response.Header; //导入依赖的package包/类
@Test
@RunAsClient
@InSequence(12)
public void testBaseMetadataTypeAndUnit() {
Header wantJson = new Header("Accept", APPLICATION_JSON);
JsonPath jsonPath = given().header(wantJson).options("/metrics/base").jsonPath();
Map<String, Map<String, Object>> elements = jsonPath.getMap(".");
Map<String, MiniMeta> expectedMetadata = getExpectedMetadataFromXmlFile(MetricRegistry.Type.BASE);
checkMetadataPresent(elements, expectedMetadata);
}
示例11: testApplicationMetadataTypeAndUnit
import com.jayway.restassured.response.Header; //导入依赖的package包/类
@Test
@RunAsClient
@InSequence(20)
public void testApplicationMetadataTypeAndUnit() {
Header wantJson = new Header("Accept", APPLICATION_JSON);
JsonPath jsonPath = given().header(wantJson).options("/metrics/application").jsonPath();
Map<String, Map<String, Object>> elements = jsonPath.getMap(".");
Map<String, MiniMeta> expectedMetadata = getExpectedMetadataFromXmlFile(MetricRegistry.Type.APPLICATION);
checkMetadataPresent(elements, expectedMetadata);
}
示例12: testConvertingToBaseUnit
import com.jayway.restassured.response.Header; //导入依赖的package包/类
@Test
@RunAsClient
@InSequence(28)
public void testConvertingToBaseUnit() {
Header wantPrometheusFormat = new Header("Accept", TEXT_PLAIN);
given().header(wantPrometheusFormat).get("/metrics/application").then().statusCode(200)
.and().body(containsString("TYPE application:org_eclipse_microprofile_metrics_test_metric_app_bean_gauge_me_a_bytes gauge"))
.and().body(containsString("TYPE application:metric_test_test1_gauge_bytes gauge"));
}
示例13: testNonStandardUnitsJSON
import com.jayway.restassured.response.Header; //导入依赖的package包/类
@Test
@RunAsClient
@InSequence(29)
public void testNonStandardUnitsJSON() {
Header wantJSONFormat = new Header("Accept", APPLICATION_JSON);
given().header(wantJSONFormat).options("/metrics/application/jellybeanHistogram").then().statusCode(200)
.body("jellybeanHistogram.unit", equalTo("jellybeans"));
}
示例14: initializeClient
import com.jayway.restassured.response.Header; //导入依赖的package包/类
private void initializeClient(Properties props)
{
if (null == props || props.size() == 0)
{
LOG.info("Loading default configuration for JIRAClient!");
InputStream configAsStream =
Thread.currentThread().getContextClassLoader()
.getResourceAsStream("jiraclient.properties");
configuration = loadInputStreamIntoProperties(configAsStream);
} else
{
configuration = props;
}
if (System.getProperty(PROXY_ENABLED, configuration.getProperty(PROXY_ENABLED, "false")).equalsIgnoreCase("true"))
{
String host = System.getProperty(PROXY_HOST, configuration.getProperty(PROXY_HOST, PROXY_HOST + " not configured in jiraclient" +
".properties!"));
String port = System.getProperty(PROXY_PORT, configuration.getProperty(PROXY_PORT, PROXY_PORT + " not configured in jiraclient" +
".properties"));
proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(host, Integer.valueOf(port.trim())));
}
theAlwaysFilter = System.getProperty(ADDITIONAL_ALWAYS_FILTER, configuration.getProperty(ADDITIONAL_ALWAYS_FILTER, ""));
authenticationHeader = new Header(configuration.getProperty(AUTH_HEADER_KEY), configuration.getProperty(AUTH_HEADER_VALUE));
velocityEngine.init();
velocityEngine.setProperty("input.encoding", "UTF-8");
velocityEngine.setProperty("output.encoding", "UTF-8");
}
示例15: attachFileToIssue
import com.jayway.restassured.response.Header; //导入依赖的package包/类
/**
* Attaches given file to the jira ticket provided.
*
* @param jiraTicket - jira ticket id
* @param fileToAttach - file path, that needs to be attached
* @throws MalformedURLException
*/
public boolean attachFileToIssue(String jiraTicket, String fileToAttach) throws MalformedURLException
{
URL request = new URL("https://" + configuration.getProperty(DEFECT_MGMT_HOST) +
configuration.getProperty(BUG_API) + "/" + jiraTicket + "/attachments");
File file = new File(fileToAttach);
RestAssured.enableLoggingOfRequestAndResponseIfValidationFails();
RequestSpecification given = RestAssured.given();
Header header2 = new Header("X-Atlassian-Token", "nocheck");
given = given.header(authenticationHeader).and().header(header2);
if (null != configuration.getProperty(PROXY_HOST))
{
given = given.proxy(configuration.getProperty(PROXY_HOST), Integer.parseInt(configuration.getProperty(PROXY_PORT)));
LOG.info("Using proxy server - " + configuration.getProperty(PROXY_HOST) + ":" +
configuration.getProperty(PROXY_PORT) + " given: " + given);
}
Response response = given
.accept(CONTENT_TYPE_APPLICATION_JSON)
.when().multiPart(file)
.post(request).then()
.extract().response();
return response.getStatusCode() == 200;
}