Search in sources :

Example 26 with ValueSource

use of org.junit.jupiter.params.provider.ValueSource in project neo4j by neo4j.

the class PropertyDeleterTest method shouldHandlePropertyChainDeletionOnDynamicRecordCycle.

@ValueSource(booleans = { true, false })
@ParameterizedTest
void shouldHandlePropertyChainDeletionOnDynamicRecordCycle(boolean log) {
    // given
    startStore(log);
    NodeStore nodeStore = neoStores.getNodeStore();
    NodeRecord node = nodeStore.newRecord();
    node.setId(nodeStore.nextId(NULL));
    List<PropertyBlock> properties = Collections.singletonList(encodedValue(0, random.randomValues().nextAsciiTextValue(1000, 1000)));
    DirectRecordAccessSet initialChanges = new DirectRecordAccessSet(neoStores, idGeneratorFactory, NULL);
    long firstPropId = propertyCreator.createPropertyChain(node, properties.iterator(), initialChanges.getPropertyRecords());
    node.setNextProp(firstPropId);
    // should update all the changed records directly into the store
    initialChanges.commit();
    // create a cycle in the dynamic record chain cycle
    PropertyRecord firstPropRecord = propertyStore.getRecord(firstPropId, propertyStore.newRecord(), RecordLoad.NORMAL, NULL);
    PropertyBlock dynamicBlock = firstPropRecord.iterator().next();
    createCycleIn(dynamicBlock);
    // when
    DirectRecordAccessSet changes = new DirectRecordAccessSet(neoStores, idGeneratorFactory, NULL);
    deleter.deletePropertyChain(node, changes.getPropertyRecords());
    changes.commit();
    // then
    assertEquals(Record.NO_NEXT_PROPERTY.longValue(), node.getNextProp());
    assertLogContains("Deleted inconsistent property chain", log);
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) NodeStore(org.neo4j.kernel.impl.store.NodeStore) PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) PropertyBlock(org.neo4j.kernel.impl.store.record.PropertyBlock) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 27 with ValueSource

use of org.junit.jupiter.params.provider.ValueSource in project neo4j by neo4j.

the class DiscardMessageTest method shouldThrowExceptionIfZero.

@ParameterizedTest
@ValueSource(longs = { -100L, 0L })
void shouldThrowExceptionIfZero(long value) throws Throwable {
    // When & Then
    BoltIOException exception = assertThrows(BoltIOException.class, () -> new DiscardMessage(asMapValue(singletonMap("n", value))));
    assertThat(exception.getMessage()).startsWith("Expecting DISCARD size to be at least 1");
}
Also used : BoltIOException(org.neo4j.bolt.messaging.BoltIOException) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 28 with ValueSource

use of org.junit.jupiter.params.provider.ValueSource in project neo4j by neo4j.

the class SslPolicyLoaderTest method correctBehaviourIfDotfilesPresent.

@ParameterizedTest
@ValueSource(booleans = { true, false })
void correctBehaviourIfDotfilesPresent(boolean ignoreDotfiles) throws IOException {
    // given
    writeJunkToFile(baseDir, ".README");
    writeJunkToFile(trustedDir, ".README");
    writeJunkToFile(revokedDir, ".README");
    // when
    SslPolicyLoader sslPolicyLoader;
    if (!ignoreDotfiles) {
        assertThrows(Exception.class, () -> createSslPolicyLoader(ignoreDotfiles));
        return;
    } else {
        sslPolicyLoader = createSslPolicyLoader(ignoreDotfiles);
    }
    SslPolicy sslPolicy = sslPolicyLoader.getPolicy(TESTING);
    // then
    assertPolicyValid(sslPolicy);
}
Also used : SslPolicyLoader(org.neo4j.ssl.config.SslPolicyLoader) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 29 with ValueSource

use of org.junit.jupiter.params.provider.ValueSource in project spring-framework by spring-projects.

the class UriComponentsBuilderTests method fromHttpRequestResetsPort80.

// gh-27097
@ParameterizedTest
@ValueSource(strings = { "http", "ws" })
void fromHttpRequestResetsPort80(String protocol) {
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.addHeader("X-Forwarded-Proto", protocol);
    request.addHeader("X-Forwarded-Host", "84.198.58.199");
    request.addHeader("X-Forwarded-Port", 80);
    request.setScheme("http");
    request.setServerName("example.com");
    request.setServerPort(80);
    request.setRequestURI("/path");
    HttpRequest httpRequest = new ServletServerHttpRequest(request);
    UriComponents result = UriComponentsBuilder.fromHttpRequest(httpRequest).build();
    assertThat(result.getScheme()).isEqualTo(protocol);
    assertThat(result.getHost()).isEqualTo("84.198.58.199");
    assertThat(result.getPort()).isEqualTo(-1);
    assertThat(result.getPath()).isEqualTo("/path");
}
Also used : HttpRequest(org.springframework.http.HttpRequest) ServletServerHttpRequest(org.springframework.http.server.ServletServerHttpRequest) ServletServerHttpRequest(org.springframework.http.server.ServletServerHttpRequest) MockHttpServletRequest(org.springframework.web.testfixture.servlet.MockHttpServletRequest) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 30 with ValueSource

use of org.junit.jupiter.params.provider.ValueSource in project spring-framework by spring-projects.

the class UriComponentsBuilderTests method fromHttpRequestResetsPort443.

// gh-17368, gh-27097
@ParameterizedTest
@ValueSource(strings = { "https", "wss" })
void fromHttpRequestResetsPort443(String protocol) {
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.addHeader("X-Forwarded-Proto", protocol);
    request.addHeader("X-Forwarded-Host", "84.198.58.199");
    request.addHeader("X-Forwarded-Port", 443);
    request.setScheme("http");
    request.setServerName("example.com");
    request.setServerPort(80);
    request.setRequestURI("/rest/mobile/users/1");
    HttpRequest httpRequest = new ServletServerHttpRequest(request);
    UriComponents result = UriComponentsBuilder.fromHttpRequest(httpRequest).build();
    assertThat(result.getScheme()).isEqualTo(protocol);
    assertThat(result.getHost()).isEqualTo("84.198.58.199");
    assertThat(result.getPort()).isEqualTo(-1);
    assertThat(result.getPath()).isEqualTo("/rest/mobile/users/1");
}
Also used : HttpRequest(org.springframework.http.HttpRequest) ServletServerHttpRequest(org.springframework.http.server.ServletServerHttpRequest) ServletServerHttpRequest(org.springframework.http.server.ServletServerHttpRequest) MockHttpServletRequest(org.springframework.web.testfixture.servlet.MockHttpServletRequest) 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