use of com.tngtech.java.junit.dataprovider.UseDataProvider in project riposte by Nike-Inc.
the class VerifyResponseHttpStatusCodeHandlingRfcCorrectnessComponentTest method verify_response_status_code_scenarios.
@Test
@UseDataProvider("responseStatusCodeScenariosDataProvider")
public void verify_response_status_code_scenarios(int desiredStatusCode, boolean shouldReturnEmptyPayload) {
for (int i = 0; i < 3; i++) {
// Run this scenario 3 times in quick succession to catch potential keep-alive connection pooling issues.
logger.info("=== RUN " + i + " ===");
String callId = UUID.randomUUID().toString();
ExtractableResponse response = given().config(config().redirect(redirectConfig().followRedirects(false))).baseUri("http://localhost").port(edgeRouterServerConfig.endpointsPort()).basePath(BackendEndpoint.MATCHING_PATH).header(BackendEndpoint.DESIRED_RESPONSE_HTTP_STATUS_CODE_HEADER_KEY, String.valueOf(desiredStatusCode)).header(BackendEndpoint.SHOULD_RETURN_EMPTY_PAYLOAD_BODY_HEADER_KEY, String.valueOf(shouldReturnEmptyPayload)).header(BackendEndpoint.CALL_ID_REQUEST_HEADER_KEY, callId).when().get().then().extract();
assertThat(response.statusCode()).isEqualTo(desiredStatusCode);
assertThat(response.header(CALL_ID_RESPONSE_HEADER_KEY)).isEqualTo(callId);
if (isContentAlwaysEmptyStatusCode(desiredStatusCode)) {
assertThat(response.asString()).isNullOrEmpty();
assertThat(response.header(CONTENT_LENGTH)).isEqualTo("0");
assertThat(response.header(TRANSFER_ENCODING)).isNull();
} else {
assertThat(response.header(CONTENT_LENGTH)).isNull();
assertThat(response.header(TRANSFER_ENCODING)).isEqualTo(CHUNKED);
if (shouldReturnEmptyPayload)
assertThat(response.asString()).isNullOrEmpty();
else
assertThat(response.asString()).isEqualTo(callId + BackendEndpoint.NON_EMPTY_PAYLOAD);
}
logger.info("=== END RUN " + i + " ===");
}
}
use of com.tngtech.java.junit.dataprovider.UseDataProvider in project riposte by Nike-Inc.
the class MediaRangeTest method test_media_range_constructor_throws_exception_with_null_values.
/**
* MediaRange constructor should throw an IllegalArgumentException when the type, subtype, or qualityFactor properties are null.
* Additionally, the constructor should throw an IllegalArgumentException when the quality factor value is less than 0 or greater than 1.
*/
@Test
@UseDataProvider("nullMediaRangeConstructorTestSet")
public void test_media_range_constructor_throws_exception_with_null_values(final String expectedErrorMessage, final ThrowingCallable callable) {
// when
Throwable ex = catchThrowable(callable);
// then
assertThat(ex).isInstanceOf(IllegalArgumentException.class).hasMessageStartingWith(expectedErrorMessage);
}
use of com.tngtech.java.junit.dataprovider.UseDataProvider in project sonarqube by SonarSource.
the class PropertiesDaoTest method selectProjectProperties_supports_all_values.
@Test
@UseDataProvider("allValuesForSelect")
public void selectProjectProperties_supports_all_values(String dbValue, String expected) throws SQLException {
ComponentDto projectDto = insertProject("A");
insertProperty("project.one", dbValue, projectDto.getId(), null);
List<PropertyDto> dtos = underTest.selectProjectProperties(projectDto.key());
assertThat(dtos).hasSize(1);
assertThatDto(dtos.iterator().next()).hasKey("project.one").hasResourceId(projectDto.getId()).hasValue(expected);
}
use of com.tngtech.java.junit.dataprovider.UseDataProvider in project sonarqube by SonarSource.
the class LogbackHelperTest method apply_accepts_any_level_as_hardcoded_level.
@Test
@UseDataProvider("logbackLevels")
public void apply_accepts_any_level_as_hardcoded_level(Level level) {
LogLevelConfig config = LogLevelConfig.newBuilder().immutableLevel("bar", level).build();
LoggerContext context = underTest.apply(config, props);
assertThat(context.getLogger("bar").getLevel()).isEqualTo(level);
}
use of com.tngtech.java.junit.dataprovider.UseDataProvider in project sonarqube by SonarSource.
the class ConditionToConditionTest method apply_converts_all_values_of_operator.
@Test
@UseDataProvider("allOperatorValues")
public void apply_converts_all_values_of_operator(Condition.Operator operator) {
Condition condition = new Condition(newMetric(METRIC_KEY), operator.getDbValue(), ERROR_THRESHOLD, WARN_THRESHOLD, true);
ConditionToCondition underTest = new ConditionToCondition(of(condition, SOME_CONDITION_STATUS));
assertThat(underTest.apply(condition).getOperator().name()).isEqualTo(operator.name());
}
Aggregations