Java Code Examples for io.restassured.RestAssured#replaceFiltersWith()

The following examples show how to use io.restassured.RestAssured#replaceFiltersWith() . 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: AllureRestAssuredTest.java    From allure-java with Apache License 2.0 6 votes vote down vote up
protected final AllureResults execute() {
    RestAssured.replaceFiltersWith(new AllureRestAssured());
    final WireMockServer server = new WireMockServer(WireMockConfiguration.options().dynamicPort());

    return runWithinTestContext(() -> {
        server.start();
        WireMock.configureFor(server.port());

        WireMock.stubFor(WireMock.get(WireMock.urlEqualTo("/hello")).willReturn(WireMock.aResponse().withBody("some body")));
        try {
            RestAssured.when().get(server.url("/hello")).then().statusCode(200);
        } finally {
            server.stop();
            RestAssured.replaceFiltersWith(ImmutableList.of());
        }
    });
}
 
Example 2
Source File: LoadRunnerFeature.java    From cukes with Apache License 2.0 5 votes vote down vote up
@Override
public void run(RunNotifier notifier) {
    RestAssured.filters(filter);
    filter.createLoadRunnerAction();
    super.run(notifier);

    try {
        File dir = new File(LOADRUNNER_OUTPUT_DIR);
        if (!dir.exists()) {
            boolean mkdirsFailed = !dir.mkdirs();
            if (mkdirsFailed) throw new CukesRuntimeException("Failed to create Folder: " + LOADRUNNER_OUTPUT_DIR);
        }

        String fileName = createName(extractFeatureName()) + ".c";
        File file = new File(LOADRUNNER_OUTPUT_DIR + File.separator + fileName);
        OutputStream out = new FileOutputStream(file);
        filter.dump(out);
        out.close();

        logger.info(file.getAbsolutePath());

        ArrayList<Filter> filtersCopy = new ArrayList<Filter>(RestAssured.filters());
        filtersCopy.remove(filter);
        RestAssured.replaceFiltersWith(filtersCopy);
    } catch (Exception e) {
        throw new CukesRuntimeException(e);
    }
}