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);
}
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");
}
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);
}
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");
}
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");
}
Aggregations