Search in sources :

Example 1 with UsageData

use of org.neo4j.udc.UsageData in project neo4j by neo4j.

the class UsageDataTest method shouldPutAndRetrieve.

@Test
public void shouldPutAndRetrieve() throws Throwable {
    // Given
    UsageData ms = new UsageData(mock(JobScheduler.class));
    UsageDataKey<String> key = key("hello");
    // When
    ms.set(key, "Hello!");
    // Then
    assertEquals("Hello!", ms.get(key));
    assertEquals(null, ms.get(key("other")));
}
Also used : JobScheduler(org.neo4j.kernel.impl.util.JobScheduler) UsageData(org.neo4j.udc.UsageData) Test(org.junit.Test)

Example 2 with UsageData

use of org.neo4j.udc.UsageData 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 3 with UsageData

use of org.neo4j.udc.UsageData in project neo4j by neo4j.

the class RESTApiModuleTest method shouldRegisterASingleUri.

@Test
public void shouldRegisterASingleUri() throws Exception {
    // Given
    WebServer webServer = mock(WebServer.class);
    Map<String, String> params = new HashMap();
    String path = "/db/data";
    params.put(ServerSettings.rest_api_path.name(), path);
    Config config = Config.embeddedDefaults(params);
    Dependencies deps = new Dependencies();
    deps.satisfyDependency(new UsageData(mock(JobScheduler.class)));
    Database db = mock(Database.class);
    // When
    RESTApiModule module = new RESTApiModule(webServer, config, deps, NullLogProvider.getInstance());
    module.start();
    // Then
    verify(webServer).addJAXRSClasses(any(List.class), anyString(), anyCollection());
}
Also used : UsageData(org.neo4j.udc.UsageData) WebServer(org.neo4j.server.web.WebServer) HashMap(java.util.HashMap) Config(org.neo4j.kernel.configuration.Config) Database(org.neo4j.server.database.Database) List(java.util.List) Matchers.anyString(org.mockito.Matchers.anyString) Dependencies(org.neo4j.kernel.impl.util.Dependencies) Test(org.junit.Test)

Aggregations

UsageData (org.neo4j.udc.UsageData)3 HashMap (java.util.HashMap)2 Test (org.junit.Test)2 List (java.util.List)1 Statement (org.junit.runners.model.Statement)1 Matchers.anyString (org.mockito.Matchers.anyString)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 Setting (org.neo4j.graphdb.config.Setting)1 AuthManager (org.neo4j.kernel.api.security.AuthManager)1 UserManagerSupplier (org.neo4j.kernel.api.security.UserManagerSupplier)1 Config (org.neo4j.kernel.configuration.Config)1 Dependencies (org.neo4j.kernel.impl.util.Dependencies)1 JobScheduler (org.neo4j.kernel.impl.util.JobScheduler)1 Database (org.neo4j.server.database.Database)1 WebServer (org.neo4j.server.web.WebServer)1 TestGraphDatabaseFactory (org.neo4j.test.TestGraphDatabaseFactory)1