Search in sources :

Example 1 with Setting

use of org.neo4j.graphdb.config.Setting in project neo4j by neo4j.

the class SessionRule method apply.

@Override
public Statement apply(final Statement base, Description description) {
    return new Statement() {

        @Override
        public void evaluate() throws Throwable {
            Map<Setting<?>, String> config = new HashMap<>();
            config.put(GraphDatabaseSettings.auth_enabled, Boolean.toString(authEnabled));
            gdb = (GraphDatabaseAPI) new TestGraphDatabaseFactory().newImpermanentDatabase(config);
            DependencyResolver resolver = gdb.getDependencyResolver();
            Authentication authentication = authentication(resolver.resolveDependency(AuthManager.class), resolver.resolveDependency(UserManagerSupplier.class));
            boltFactory = new BoltFactoryImpl(gdb, new UsageData(null), NullLogService.getInstance(), resolver.resolveDependency(ThreadToStatementContextBridge.class), authentication, BoltConnectionTracker.NOOP, Config.defaults());
            boltFactory.start();
            try {
                base.evaluate();
            } finally {
                try {
                    if (runningMachines != null) {
                        runningMachines.forEach(BoltStateMachine::close);
                    }
                } catch (Throwable e) {
                    e.printStackTrace();
                }
                gdb.shutdown();
            }
        }
    };
}
Also used : UsageData(org.neo4j.udc.UsageData) HashMap(java.util.HashMap) AuthManager(org.neo4j.kernel.api.security.AuthManager) Statement(org.junit.runners.model.Statement) Setting(org.neo4j.graphdb.config.Setting) UserManagerSupplier(org.neo4j.kernel.api.security.UserManagerSupplier) DependencyResolver(org.neo4j.graphdb.DependencyResolver) BoltFactoryImpl(org.neo4j.bolt.v1.runtime.BoltFactoryImpl) BoltStateMachine(org.neo4j.bolt.v1.runtime.BoltStateMachine) Authentication(org.neo4j.bolt.security.auth.Authentication) BasicAuthentication(org.neo4j.bolt.security.auth.BasicAuthentication) TestGraphDatabaseFactory(org.neo4j.test.TestGraphDatabaseFactory)

Example 2 with Setting

use of org.neo4j.graphdb.config.Setting in project neo4j by neo4j.

the class HttpConnectorValidatorTest method setsDeprecationFlagOnEncryption.

@Test
public void setsDeprecationFlagOnEncryption() throws Exception {
    Setting setting = cv.getSettingFor("dbms.connector.http.encryption", Collections.emptyMap()).orElseThrow(() -> new RuntimeException("missing setting!"));
    assertTrue(setting.deprecated());
    assertEquals(Optional.empty(), setting.replacement());
}
Also used : Setting(org.neo4j.graphdb.config.Setting) Test(org.junit.Test)

Example 3 with Setting

use of org.neo4j.graphdb.config.Setting in project neo4j by neo4j.

the class HttpConnectorValidatorTest method sdfa.

@Test
public void sdfa() throws Exception {
    Setting setting = cv.getSettingFor("dbms.connector.http.type", Collections.emptyMap()).orElseThrow(() -> new RuntimeException("missing setting!"));
    assertTrue(setting.deprecated());
    assertEquals(Optional.empty(), setting.replacement());
}
Also used : Setting(org.neo4j.graphdb.config.Setting) Test(org.junit.Test)

Example 4 with Setting

use of org.neo4j.graphdb.config.Setting in project neo4j by neo4j.

the class HttpConnectorValidatorTest method setsDeprecationFlagOnCustomNamedHttpConnectors.

@Test
public void setsDeprecationFlagOnCustomNamedHttpConnectors() throws Exception {
    List<Setting<Object>> settings = cv.settings(stringMap("dbms.connector.0.type", "HTTP", "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.encryption", Encryption.NONE.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 (!"encryption".equals(parts[3]) && !"type".equals(parts[3])) {
            assertEquals(Optional.of(format("%s.%s.%s.%s", parts[0], parts[1], "http", parts[3])), s.replacement());
        }
    }
}
Also used : Setting(org.neo4j.graphdb.config.Setting) Test(org.junit.Test)

Example 5 with Setting

use of org.neo4j.graphdb.config.Setting in project neo4j by neo4j.

the class BoltConnectorValidatorTest method setsDeprecationFlagOnAddress.

@Test
public void setsDeprecationFlagOnAddress() throws Exception {
    Setting setting = cv.getSettingFor("dbms.connector.bolt.address", Collections.emptyMap()).orElseThrow(() -> new RuntimeException("missing setting!"));
    assertTrue(setting.deprecated());
    assertEquals(Optional.of("dbms.connector.bolt.listen_address"), setting.replacement());
}
Also used : Setting(org.neo4j.graphdb.config.Setting) Test(org.junit.Test)

Aggregations

Setting (org.neo4j.graphdb.config.Setting)15 Test (org.junit.Test)10 HashMap (java.util.HashMap)4 Field (java.lang.reflect.Field)2 Map (java.util.Map)2 TestGraphDatabaseFactory (org.neo4j.test.TestGraphDatabaseFactory)2 IOException (java.io.IOException)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1 Statement (org.junit.runners.model.Statement)1 Authentication (org.neo4j.bolt.security.auth.Authentication)1 BasicAuthentication (org.neo4j.bolt.security.auth.BasicAuthentication)1 BoltFactoryImpl (org.neo4j.bolt.v1.runtime.BoltFactoryImpl)1 BoltStateMachine (org.neo4j.bolt.v1.runtime.BoltStateMachine)1 DependencyResolver (org.neo4j.graphdb.DependencyResolver)1 GraphDatabaseBuilder (org.neo4j.graphdb.factory.GraphDatabaseBuilder)1 MapUtil.stringMap (org.neo4j.helpers.collection.MapUtil.stringMap)1 AuthManager (org.neo4j.kernel.api.security.AuthManager)1 UserManagerSupplier (org.neo4j.kernel.api.security.UserManagerSupplier)1 TestGraphDatabaseBuilder (org.neo4j.test.TestGraphDatabaseBuilder)1 UsageData (org.neo4j.udc.UsageData)1