use of org.neo4j.graphdb.config.Setting in project neo4j by neo4j.
the class BoltConnectorValidatorTest method setsDeprecationFlagOnType.
@Test
public void setsDeprecationFlagOnType() throws Exception {
Setting setting = cv.getSettingFor("dbms.connector.bolt.type", Collections.emptyMap()).orElseThrow(() -> new RuntimeException("missing setting!"));
assertTrue(setting.deprecated());
assertEquals(Optional.empty(), setting.replacement());
}
use of org.neo4j.graphdb.config.Setting in project neo4j by neo4j.
the class DefaultUdcInformationCollector method determineClusterNameHash.
private Integer determineClusterNameHash() {
try {
Class<?> settings = Class.forName("org.neo4j.cluster.ClusterSettings");
Setting setting = (Setting) settings.getField("cluster_name").get(null);
Object name = config.get(setting);
return name != null ? Math.abs(name.hashCode() % Integer.MAX_VALUE) : null;
} catch (Exception e) {
return null;
}
}
use of org.neo4j.graphdb.config.Setting in project neo4j by neo4j.
the class SystemPropertiesConfiguration method apply.
public Map<String, String> apply(Map<String, String> config) {
// Create test config with base plus system props on top
Map<String, String> systemProperties = new HashMap<>(config);
for (Map.Entry<Object, Object> prop : System.getProperties().entrySet()) {
systemProperties.put(prop.getKey().toString(), prop.getValue().toString());
}
// For each system property, see if it passes validation
// If so, add it to result set
Map<String, String> result = new HashMap<String, String>(config);
Function<String, String> systemPropertiesFunction = systemProperties::get;
for (Map.Entry<Object, Object> prop : System.getProperties().entrySet()) {
String key = (String) prop.getKey();
for (Class<?> settingsClass : settingsClasses) {
for (Field field : settingsClass.getFields()) {
try {
Setting<Object> setting = (Setting<Object>) field.get(null);
if (setting.name().equals(key)) {
setting.apply(systemPropertiesFunction);
// Valid setting, copy it from system properties
result.put(key, (String) prop.getValue());
}
} catch (Throwable e) {
continue;
}
}
}
}
return result;
}
use of org.neo4j.graphdb.config.Setting in project neo4j by neo4j.
the class GraphDatabaseSettingsTest method noDuplicateSettingsAreAllowed.
@Test
public void noDuplicateSettingsAreAllowed() throws Exception {
final HashMap<String, String> fields = new HashMap<>();
for (Field field : GraphDatabaseSettings.class.getDeclaredFields()) {
if (field.getType() == Setting.class) {
Setting setting = (Setting) field.get(null);
assertFalse(String.format("'%s' in %s has already been defined in %s", setting.name(), field.getName(), fields.get(setting.name())), fields.containsKey(setting.name()));
fields.put(setting.name(), field.getName());
}
}
}
use of org.neo4j.graphdb.config.Setting in project neo4j by neo4j.
the class BoltConnectorValidatorTest method setsDeprecationFlagOnCustomNamedBoltConnectors.
@Test
public void setsDeprecationFlagOnCustomNamedBoltConnectors() throws Exception {
List<Setting<Object>> settings = cv.settings(stringMap("dbms.connector.0.type", "BOLT", "dbms.connector.0.enabled", "false", "dbms.connector.0.listen_address", "1.2.3.4:123", "dbms.connector.0.advertised_address", "localhost:123", "dbms.connector.0.tls_level", EncryptionLevel.OPTIONAL.toString()));
assertEquals(5, settings.size());
for (Setting s : settings) {
assertTrue("every setting should be deprecated: " + s.name(), s.deprecated());
String[] parts = s.name().split("\\.");
if (!"type".equals(parts[3])) {
assertEquals(Optional.of(format("%s.%s.%s.%s", parts[0], parts[1], "bolt", parts[3])), s.replacement());
}
}
}
Aggregations