use of org.junit.jupiter.params.provider.ValueSource in project gocd by gocd.
the class ArtifactSizeEnforcementFilterChainTest method shouldDisallowIfNotEnoughDiskSpaceIsAvailable.
@ParameterizedTest
@ValueSource(strings = { "/files/bar/foo.zip", "/remoting/files/bar/foo.zip" })
void shouldDisallowIfNotEnoughDiskSpaceIsAvailable(String path) throws IOException, ServletException {
MockHttpServletRequest request = HttpRequestBuilder.POST(path).withHeader("X-GO-ARTIFACT-SIZE", FileSize.valueOf("600MB").getSize()).build();
filter.doFilter(request, response, filterChain);
assertThat(response).isEntityTooLarge();
verify(filterChain, never()).doFilter(request, response);
}
use of org.junit.jupiter.params.provider.ValueSource in project gocd by gocd.
the class RequestRejectedExceptionHandlerTest method shouldHandleUrlsAsApiRequest.
@ParameterizedTest
@ValueSource(strings = { "/remoting/foo", "/add-on/bar/api/foo", "/api/foo", "/cctray.xml" })
void shouldHandleUrlsAsApiRequest(String url) throws IOException {
final MockHttpServletRequest request = HttpRequestBuilder.GET(url).withHeader("Accept", "application/json").build();
final MockHttpServletResponse response = new MockHttpServletResponse();
new RequestRejectedExceptionHandler().handle(request, response, "Something went wrong", HttpStatus.BAD_REQUEST);
assertThat(response).isBadRequest().hasBody("{\n" + " \"message\": \"Something went wrong\"\n" + "}");
}
use of org.junit.jupiter.params.provider.ValueSource in project HdrHistogram by HdrHistogram.
the class DoubleHistogramTest method testLowestEquivalentValue.
@ParameterizedTest
@ValueSource(classes = { DoubleHistogram.class, ConcurrentDoubleHistogram.class, SynchronizedDoubleHistogram.class, PackedDoubleHistogram.class, PackedConcurrentDoubleHistogram.class })
public void testLowestEquivalentValue(final Class histoClass) {
DoubleHistogram histogram = constructDoubleHistogram(histoClass, trackableValueRangeSize, numberOfSignificantValueDigits);
histogram.recordValue(1.0);
assertEquals("The lowest equivalent value to 10007 is 10000", 10000, histogram.lowestEquivalentValue(10007), 0.001);
assertEquals("The lowest equivalent value to 10009 is 10008", 10008, histogram.lowestEquivalentValue(10009), 0.001);
}
use of org.junit.jupiter.params.provider.ValueSource in project HdrHistogram by HdrHistogram.
the class DoubleHistogramTest method testRecordValue.
@ParameterizedTest
@ValueSource(classes = { DoubleHistogram.class, ConcurrentDoubleHistogram.class, SynchronizedDoubleHistogram.class, PackedDoubleHistogram.class, PackedConcurrentDoubleHistogram.class })
public void testRecordValue(Class histoClass) throws Exception {
DoubleHistogram histogram = constructDoubleHistogram(histoClass, trackableValueRangeSize, numberOfSignificantValueDigits);
histogram.recordValue(testValueLevel);
assertEquals(1L, histogram.getCountAtValue(testValueLevel));
assertEquals(1L, histogram.getTotalCount());
}
use of org.junit.jupiter.params.provider.ValueSource in project HdrHistogram by HdrHistogram.
the class DoubleHistogramTest method testCopyInto.
@ParameterizedTest
@ValueSource(classes = { DoubleHistogram.class, ConcurrentDoubleHistogram.class, SynchronizedDoubleHistogram.class, PackedDoubleHistogram.class, PackedConcurrentDoubleHistogram.class })
public void testCopyInto(final Class histoClass) throws Exception {
DoubleHistogram histogram = new DoubleHistogram(trackableValueRangeSize, numberOfSignificantValueDigits);
DoubleHistogram targetHistogram = new DoubleHistogram(trackableValueRangeSize, numberOfSignificantValueDigits);
histogram.recordValue(testValueLevel);
histogram.recordValue(testValueLevel * 10);
histogram.recordValueWithExpectedInterval(histogram.getCurrentHighestTrackableValue() - 1, histogram.getCurrentHighestTrackableValue() / 1000);
System.out.println("Testing copyInto for DoubleHistogram:");
histogram.copyInto(targetHistogram);
assertEqual(histogram, targetHistogram);
histogram.recordValue(testValueLevel * 20);
histogram.copyInto(targetHistogram);
assertEqual(histogram, targetHistogram);
DoubleHistogram withIntHistogram = new DoubleHistogram(trackableValueRangeSize, numberOfSignificantValueDigits, IntCountsHistogram.class);
DoubleHistogram targetWithIntHistogram = new DoubleHistogram(trackableValueRangeSize, numberOfSignificantValueDigits, IntCountsHistogram.class);
withIntHistogram.recordValue(testValueLevel);
withIntHistogram.recordValue(testValueLevel * 10);
withIntHistogram.recordValueWithExpectedInterval(withIntHistogram.getCurrentHighestTrackableValue() - 1, withIntHistogram.getCurrentHighestTrackableValue() / 1000);
System.out.println("Testing copyInto for DoubleHistogram backed by IntHistogram:");
withIntHistogram.copyInto(targetWithIntHistogram);
assertEqual(withIntHistogram, targetWithIntHistogram);
withIntHistogram.recordValue(testValueLevel * 20);
withIntHistogram.copyInto(targetWithIntHistogram);
assertEqual(withIntHistogram, targetWithIntHistogram);
DoubleHistogram withShortHistogram = new DoubleHistogram(trackableValueRangeSize, numberOfSignificantValueDigits, ShortCountsHistogram.class);
DoubleHistogram targetWithShortHistogram = new DoubleHistogram(trackableValueRangeSize, numberOfSignificantValueDigits, ShortCountsHistogram.class);
withShortHistogram.recordValue(testValueLevel);
withShortHistogram.recordValue(testValueLevel * 10);
withShortHistogram.recordValueWithExpectedInterval(withShortHistogram.getCurrentHighestTrackableValue() - 1, withShortHistogram.getCurrentHighestTrackableValue() / 1000);
System.out.println("Testing copyInto for DoubleHistogram backed by a ShortHistogram:");
withShortHistogram.copyInto(targetWithShortHistogram);
assertEqual(withShortHistogram, targetWithShortHistogram);
withShortHistogram.recordValue(testValueLevel * 20);
withShortHistogram.copyInto(targetWithShortHistogram);
assertEqual(withShortHistogram, targetWithShortHistogram);
DoubleHistogram withConcurrentHistogram = new DoubleHistogram(trackableValueRangeSize, numberOfSignificantValueDigits, ConcurrentHistogram.class);
DoubleHistogram targetWithConcurrentHistogram = new DoubleHistogram(trackableValueRangeSize, numberOfSignificantValueDigits, ConcurrentHistogram.class);
withConcurrentHistogram.recordValue(testValueLevel);
withConcurrentHistogram.recordValue(testValueLevel * 10);
withConcurrentHistogram.recordValueWithExpectedInterval(withConcurrentHistogram.getCurrentHighestTrackableValue() - 1, withConcurrentHistogram.getCurrentHighestTrackableValue() / 1000);
System.out.println("Testing copyInto for DoubleHistogram backed by ConcurrentHistogram:");
withConcurrentHistogram.copyInto(targetWithConcurrentHistogram);
assertEqual(withConcurrentHistogram, targetWithConcurrentHistogram);
withConcurrentHistogram.recordValue(testValueLevel * 20);
withConcurrentHistogram.copyInto(targetWithConcurrentHistogram);
assertEqual(withConcurrentHistogram, targetWithConcurrentHistogram);
ConcurrentDoubleHistogram concurrentHistogram = new ConcurrentDoubleHistogram(trackableValueRangeSize, numberOfSignificantValueDigits);
ConcurrentDoubleHistogram targetConcurrentHistogram = new ConcurrentDoubleHistogram(trackableValueRangeSize, numberOfSignificantValueDigits);
concurrentHistogram.recordValue(testValueLevel);
concurrentHistogram.recordValue(testValueLevel * 10);
concurrentHistogram.recordValueWithExpectedInterval(concurrentHistogram.getCurrentHighestTrackableValue() - 1, concurrentHistogram.getCurrentHighestTrackableValue() / 1000);
System.out.println("Testing copyInto for actual ConcurrentHistogram:");
concurrentHistogram.copyInto(targetConcurrentHistogram);
assertEqual(concurrentHistogram, targetConcurrentHistogram);
concurrentHistogram.recordValue(testValueLevel * 20);
concurrentHistogram.copyInto(targetConcurrentHistogram);
assertEqual(concurrentHistogram, targetConcurrentHistogram);
DoubleHistogram withSyncHistogram = new DoubleHistogram(trackableValueRangeSize, numberOfSignificantValueDigits, SynchronizedHistogram.class);
DoubleHistogram targetWithSyncHistogram = new DoubleHistogram(trackableValueRangeSize, numberOfSignificantValueDigits, SynchronizedHistogram.class);
withSyncHistogram.recordValue(testValueLevel);
withSyncHistogram.recordValue(testValueLevel * 10);
withSyncHistogram.recordValueWithExpectedInterval(withSyncHistogram.getCurrentHighestTrackableValue() - 1, withSyncHistogram.getCurrentHighestTrackableValue() / 1000);
System.out.println("Testing copyInto for DoubleHistogram backed by SynchronizedHistogram:");
withSyncHistogram.copyInto(targetWithSyncHistogram);
assertEqual(withSyncHistogram, targetWithSyncHistogram);
withSyncHistogram.recordValue(testValueLevel * 20);
withSyncHistogram.copyInto(targetWithSyncHistogram);
assertEqual(withSyncHistogram, targetWithSyncHistogram);
SynchronizedDoubleHistogram syncHistogram = new SynchronizedDoubleHistogram(trackableValueRangeSize, numberOfSignificantValueDigits);
SynchronizedDoubleHistogram targetSyncHistogram = new SynchronizedDoubleHistogram(trackableValueRangeSize, numberOfSignificantValueDigits);
syncHistogram.recordValue(testValueLevel);
syncHistogram.recordValue(testValueLevel * 10);
syncHistogram.recordValueWithExpectedInterval(syncHistogram.getCurrentHighestTrackableValue() - 1, syncHistogram.getCurrentHighestTrackableValue() / 1000);
System.out.println("Testing copyInto for actual SynchronizedDoubleHistogram:");
syncHistogram.copyInto(targetSyncHistogram);
assertEqual(syncHistogram, targetSyncHistogram);
syncHistogram.recordValue(testValueLevel * 20);
syncHistogram.copyInto(targetSyncHistogram);
assertEqual(syncHistogram, targetSyncHistogram);
}
Aggregations