Search in sources :

Example 96 with ValueSource

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);
}
Also used : MockHttpServletRequest(com.thoughtworks.go.http.mocks.MockHttpServletRequest) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 97 with ValueSource

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" + "}");
}
Also used : MockHttpServletRequest(com.thoughtworks.go.http.mocks.MockHttpServletRequest) MockHttpServletResponse(com.thoughtworks.go.http.mocks.MockHttpServletResponse) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 98 with ValueSource

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);
}
Also used : HistogramTestUtils.constructDoubleHistogram(org.HdrHistogram.HistogramTestUtils.constructDoubleHistogram) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 99 with ValueSource

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());
}
Also used : HistogramTestUtils.constructDoubleHistogram(org.HdrHistogram.HistogramTestUtils.constructDoubleHistogram) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 100 with ValueSource

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);
}
Also used : HistogramTestUtils.constructDoubleHistogram(org.HdrHistogram.HistogramTestUtils.constructDoubleHistogram) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)266 ValueSource (org.junit.jupiter.params.provider.ValueSource)266 HashSet (java.util.HashSet)23 HistogramTestUtils.constructDoubleHistogram (org.HdrHistogram.HistogramTestUtils.constructDoubleHistogram)23 ArrayList (java.util.ArrayList)22 HashMap (java.util.HashMap)20 ApiResponse (org.hisp.dhis.dto.ApiResponse)15 UpdateModel (com.synopsys.integration.alert.update.model.UpdateModel)13 File (java.io.File)13 List (java.util.List)13 OffsetDateTime (java.time.OffsetDateTime)10 Map (java.util.Map)10 TimeUnit (java.util.concurrent.TimeUnit)10 TopicPartition (org.apache.kafka.common.TopicPartition)9 ListenerSubscribeMessage (io.nem.symbol.sdk.infrastructure.ListenerSubscribeMessage)8 UnresolvedAddress (io.nem.symbol.sdk.model.account.UnresolvedAddress)8 ZooKeeper (org.apache.zookeeper.ZooKeeper)8 JsonObject (com.google.gson.JsonObject)7 IOException (java.io.IOException)7 CountDownLatch (java.util.concurrent.CountDownLatch)7