Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Commit

Permalink
2.0.0 SNAPSHOT
Browse files Browse the repository at this point in the history
Performance assertions API;
Jersey & Swagger integration;
Mockserver -> Wiremock migration;
  • Loading branch information
kiturutin committed Jul 12, 2019
1 parent 0721455 commit 889aeda
Show file tree
Hide file tree
Showing 130 changed files with 9,342 additions and 1,507 deletions.
11 changes: 1 addition & 10 deletions browserup-proxy-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,7 @@ dependencies {
testImplementation "org.eclipse.jetty:jetty-servlets:${jettyVersion}"
testImplementation 'org.hamcrest:hamcrest:2.1'
testImplementation 'org.hamcrest:hamcrest-library:2.1'
testImplementation ('org.mock-server:mockserver-netty:5.6.0') {
exclude(module: 'logback-classic')
exclude(module: 'netty-codec-socks')
exclude(module: 'netty-buffer')
exclude(module: 'netty-codec')
exclude(module: 'netty-codec-http')
exclude(module: 'netty-common')
exclude(module: 'netty-handler')
exclude(module: 'netty-transport')
}
testImplementation 'com.github.tomakehurst:wiremock-jre8:2.22.0'
testImplementation 'org.mockito:mockito-core:3.0.0'
testImplementation 'org.seleniumhq.selenium:selenium-firefox-driver:3.141.59'
testImplementation 'org.apache.httpcomponents:httpclient:4.5.9'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@

package com.browserup.bup;

import com.browserup.bup.assertion.HarEntryAssertion;
import com.browserup.bup.assertion.model.AssertionResult;
import com.browserup.bup.assertion.supplier.HarEntriesSupplier;
import com.browserup.bup.util.HttpStatusClass;
import com.browserup.harreader.model.Har;
import com.browserup.bup.filters.RequestFilter;
import com.browserup.bup.filters.ResponseFilter;
Expand All @@ -23,7 +22,6 @@
import java.net.InetSocketAddress;
import java.util.Collection;
import java.util.EnumSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
Expand Down Expand Up @@ -685,5 +683,289 @@ public interface BrowserUpProxy {
*/
Collection<HarEntry> findEntries(Pattern url);

AssertionResult assertMostRecentUrlResponseTimeWithin(Pattern url, long time);
/**
* Assert that the response time for the most recent request
* found by a given URL pattern is less than or equal to a given number of milliseconds.
* @param url Regular expression match of URL to find.
* See examples {@link com.browserup.bup.BrowserUpProxy#findEntries(java.util.regex.Pattern)}
* @param milliseconds Maximum time in milliseconds, inclusive.
* @return Assertion result
*/
AssertionResult assertMostRecentResponseTimeLessThanOrEqual(Pattern url, long milliseconds);

/**
* Assert that the response times for all requests
* found by a given URL pattern are less than or equal to a given number of milliseconds.
* @param url Regular expression match of URL to find.
* See examples {@link com.browserup.bup.BrowserUpProxy#findEntries(java.util.regex.Pattern)}
* @param milliseconds Maximum time in milliseconds, inclusive.
* @return Assertion result
*/
AssertionResult assertResponseTimeLessThanOrEqual(Pattern url, long milliseconds);

/**
* Assert that response content for the most recent request found by a given URL pattern contains specified value.
* @param url Regular expression match of URL to find.
* See examples {@link com.browserup.bup.BrowserUpProxy#findEntries(java.util.regex.Pattern)}
* @param text String to search in the content
* @return Assertion result
*/
AssertionResult assertMostRecentResponseContentContains(Pattern url, String text);

/**
* Assert that response content for the most recent request
* found by a given URL pattern doesn't contain specified value.
* @param url Regular expression match of URL to find.
* See examples {@link com.browserup.bup.BrowserUpProxy#findEntries(java.util.regex.Pattern)}
* @param text String to search in the content
* @return Assertion result
*/
AssertionResult assertMostRecentResponseContentDoesNotContain(Pattern url, String text);

/**
* Assert that response content for the most recent request
* found by a given URL pattern matches content pattern.
* @param url Regular expression match of URL to find.
* See examples {@link com.browserup.bup.BrowserUpProxy#findEntries(java.util.regex.Pattern)}
* @param contentPattern Regular expression match of content to find.
* @return Assertion result
*/
AssertionResult assertMostRecentResponseContentMatches(Pattern url, Pattern contentPattern);

/**
* Assert that content length of all responses found by url pattern do not exceed max value.
* @param url Regular expression match of URL to find.
* See examples {@link com.browserup.bup.BrowserUpProxy#findEntries(java.util.regex.Pattern)}
* @param max Max length of content, inclusive
* @return Assertion result
*/
AssertionResult assertAnyUrlContentLengthLessThanOrEquals(Pattern url, Long max);

/**
* Assert that responses content for all requests found by url pattern matches content pattern.
* @param url Regular expression match of URL to find.
* See examples {@link com.browserup.bup.BrowserUpProxy#findEntries(java.util.regex.Pattern)}
* @param contentPattern Regular expression match of content to find.
* @return Assertion result
*/
AssertionResult assertAnyUrlContentMatches(Pattern url, Pattern contentPattern);

/**
* Assert that responses content for all requests found by a given URL pattern contain specified value.
* @param url Regular expression match of URL to find.
* See examples {@link com.browserup.bup.BrowserUpProxy#findEntries(java.util.regex.Pattern)}
* @param text String to search in the content
* @return Assertion result
*/
AssertionResult assertAnyUrlContentContains(Pattern url, String text);

/**
* Assert that responses content for all requests found by a given URL pattern don't contain specified value.
* @param url Regular expression match of URL to find.
* See examples {@link com.browserup.bup.BrowserUpProxy#findEntries(java.util.regex.Pattern)}
* @param text String to search in the content
* @return Assertion result
*/
AssertionResult assertAnyUrlContentDoesNotContain(Pattern url, String text);

/**
* Assert that headers of all responses found by url pattern contain specified value.
* @param url Regular expression match of URL to find.
* See examples {@link com.browserup.bup.BrowserUpProxy#findEntries(java.util.regex.Pattern)}
* @param value Header value
* @return Assertion result
*/
AssertionResult assertAnyUrlResponseHeaderContains(Pattern url, String value);

/**
* Assert that if responses found by url pattern have headers with specified name
* - among them must be one header with value containing specified text.
* @param url Regular expression match of URL to find.
* See examples {@link com.browserup.bup.BrowserUpProxy#findEntries(java.util.regex.Pattern)}
* @param name Header name
* @param value Header value
* @return Assertion result
*/
AssertionResult assertAnyUrlResponseHeaderContains(Pattern url, String name, String value);

/**
* Assert that headers of all responses found by url pattern don't contain specified value.
* @param url Regular expression match of URL to find.
* See examples {@link com.browserup.bup.BrowserUpProxy#findEntries(java.util.regex.Pattern)}
* @param value Header value
* @return Assertion result
*/
AssertionResult assertAnyUrlResponseHeaderDoesNotContain(Pattern url, String value);

/**
* Assert that if responses found by url pattern have headers with specified name
* - their values must not contain specified value.
* @param url Regular expression match of URL to find.
* See examples {@link com.browserup.bup.BrowserUpProxy#findEntries(java.util.regex.Pattern)}
* @param name Header name
* @param value Header value
* @return Assertion result
*/
AssertionResult assertAnyUrlResponseHeaderDoesNotContain(Pattern url, String name, String value);

/**
* Assert that all headers of all responses found by url pattern have values matching value pattern.
* @param url Regular expression match of URL to find.
* See examples {@link com.browserup.bup.BrowserUpProxy#findEntries(java.util.regex.Pattern)}
* @param valuePattern Regular expression match of header value.
* @return Assertion result
*/
default AssertionResult assertAnyUrlResponseHeaderMatches(Pattern url, Pattern valuePattern) {
return assertAnyUrlResponseHeaderMatches(url, null, valuePattern);
}

/**
* Assert that if responses found by url pattern have headers with name
* found by name pattern - their values should match value pattern.
* @param url Regular expression match of URL to find.
* See examples {@link com.browserup.bup.BrowserUpProxy#findEntries(java.util.regex.Pattern)}
* @param namePattern Regular expression match of header name to find.
* @param valuePattern Regular expression match of header value.
* @return Assertion result
*/
AssertionResult assertAnyUrlResponseHeaderMatches(Pattern url, Pattern namePattern, Pattern valuePattern);

/**
* Assert that if the most recent response found by url pattern has header with specified name
* - it's value must contain specified text.
* @param url Regular expression match of URL to find.
* See examples {@link com.browserup.bup.BrowserUpProxy#findEntries(java.util.regex.Pattern)}
* @param name Header name
* @param value Header value
* @return Assertion result
*/
AssertionResult assertMostRecentResponseHeaderContains(Pattern url, String name, String value);

/**
* Assert that headers of the most recent response found by url pattern contain specified value.
* @param url Regular expression match of URL to find.
* See examples {@link com.browserup.bup.BrowserUpProxy#findEntries(java.util.regex.Pattern)}
* @param value Header value
* @return Assertion result
*/
default AssertionResult assertMostRecentResponseHeaderContains(Pattern url, String value) {
return assertMostRecentResponseHeaderContains(url, null, value);
}

/**
* Assert that if the most recent response found by url pattern has header with specified name
* - it's value must not contain specified text.
* @param url Regular expression match of URL to find.
* See examples {@link com.browserup.bup.BrowserUpProxy#findEntries(java.util.regex.Pattern)}
* @param name Header name
* @param value Header value
* @return Assertion result
*/
AssertionResult assertMostRecentResponseHeaderDoesNotContain(Pattern url, String name, String value);

/**
* Assert that headers of the most recent response found by url pattern do not contain specified value.
* @param url Regular expression match of URL to find.
* See examples {@link com.browserup.bup.BrowserUpProxy#findEntries(java.util.regex.Pattern)}
* @param value Header value
* @return Assertion result
*/
default AssertionResult assertMostRecentResponseHeaderDoesNotContain(Pattern url, String value) {
return assertMostRecentResponseHeaderDoesNotContain(url, null, value);
}

/**
* Assert that if the most recent response found by url pattern has header with name
* found by name pattern - it's value should match value pattern.
* @param url Regular expression match of URL to find.
* See examples {@link com.browserup.bup.BrowserUpProxy#findEntries(java.util.regex.Pattern)}
* @param name Regular expression match of header name to find.
* @param value Regular expression match of header value.
* @return Assertion result
*/
AssertionResult assertMostRecentResponseHeaderMatches(Pattern url, Pattern name, Pattern value);

/**
* Assert that all headers of the most recent response found by url pattern have values matching value pattern.
* @param url Regular expression match of URL to find.
* See examples {@link com.browserup.bup.BrowserUpProxy#findEntries(java.util.regex.Pattern)}
* @param value Regular expression match of header value.
* @return Assertion result
*/
default AssertionResult assertMostRecentResponseHeaderMatches(Pattern url, Pattern value) {
return assertMostRecentResponseHeaderMatches(url, null, value);
}

/**
* Assert that content length of the most recent response found by url pattern does not exceed max value.
* @param url Regular expression match of URL to find.
* See examples {@link com.browserup.bup.BrowserUpProxy#findEntries(java.util.regex.Pattern)}
* @param max Max length of content, inclusive
* @return Assertion result
*/
AssertionResult assertMostRecentResponseContentLengthLessThanOrEqual(Pattern url, Long max);

/**
* Assert that all responses of current step have specified status.
* @param status Expected http status
* @return Assertion result
*/
AssertionResult assertResponseStatusCode(Integer status);

/**
* Assert that all responses of current step have statuses belonging to the same class.
* @param clazz Http status class
* @return Assertion result
*/
AssertionResult assertResponseStatusCode(HttpStatusClass clazz);

/**
* Assert that all responses found by url pattern have specified http status.
* @param url Regular expression match of URL to find.
* See examples {@link com.browserup.bup.BrowserUpProxy#findEntries(java.util.regex.Pattern)}
* @param status Http status
* @return Assertion result
*/
AssertionResult assertResponseStatusCode(Pattern url, Integer status);

/**
* Assert that all responses found by url pattern have statuses belonging to the same class.
* @param url Regular expression match of URL to find.
* See examples {@link com.browserup.bup.BrowserUpProxy#findEntries(java.util.regex.Pattern)}
* @param clazz Http status class
* @return Assertion result
*/
AssertionResult assertResponseStatusCode(Pattern url, HttpStatusClass clazz);

/**
* Assert that the most recent response has specified status.
* @param status Http status
* @return Assertion result
*/
AssertionResult assertMostRecentResponseStatusCode(Integer status);

/**
* Assert that the most recent response has status belonging to specified class.
* @param clazz Http status class
* @return Assertion result
*/
AssertionResult assertMostRecentResponseStatusCode(HttpStatusClass clazz);

/**
* Assert that the most recent response found by url pattern has specified status.
* @param url Regular expression match of URL to find.
* See examples {@link com.browserup.bup.BrowserUpProxy#findEntries(java.util.regex.Pattern)}
* @param status Http status
* @return Assertion result
*/
AssertionResult assertMostRecentResponseStatusCode(Pattern url, Integer status);

/**
* Assert that the most recent response found by url pattern has status belonging to specified class.
* @param url Regular expression match of URL to find.
* See examples {@link com.browserup.bup.BrowserUpProxy#findEntries(java.util.regex.Pattern)}
* @param clazz Http status class
* @return Assertion result
*/
AssertionResult assertMostRecentResponseStatusCode(Pattern url, HttpStatusClass clazz);
}
Loading

0 comments on commit 889aeda

Please sign in to comment.