Search in sources :

Example 1 with GlobalExtensionContext

use of org.neo4j.kernel.extension.context.GlobalExtensionContext in project neo4j by neo4j.

the class ExtensionContextTest method shouldConsultUnsatisfiedDependencyHandlerOnMissingDependencies.

@Test
void shouldConsultUnsatisfiedDependencyHandlerOnMissingDependencies() {
    GlobalExtensionContext context = mock(GlobalExtensionContext.class);
    ExtensionFailureStrategy handler = mock(ExtensionFailureStrategy.class);
    // that hasn't got anything.
    Dependencies dependencies = new Dependencies();
    TestingExtensionFactory extensionFactory = new TestingExtensionFactory();
    GlobalExtensions extensions = new GlobalExtensions(context, iterable(extensionFactory), dependencies, handler);
    try (Lifespan ignored = new Lifespan(extensions)) {
        verify(handler).handle(eq(extensionFactory), any(UnsatisfiedDependencyException.class));
    }
}
Also used : UnsatisfiedDependencyException(org.neo4j.exceptions.UnsatisfiedDependencyException) Dependencies(org.neo4j.collection.Dependencies) Lifespan(org.neo4j.kernel.lifecycle.Lifespan) GlobalExtensionContext(org.neo4j.kernel.extension.context.GlobalExtensionContext) Test(org.junit.jupiter.api.Test)

Example 2 with GlobalExtensionContext

use of org.neo4j.kernel.extension.context.GlobalExtensionContext in project neo4j by neo4j.

the class ExtensionContextTest method globalContextRootDirectoryEqualToStoreDirectory.

@Test
void globalContextRootDirectoryEqualToStoreDirectory() {
    GlobalExtensionContext context = new GlobalExtensionContext(neo4jLayout, DbmsInfo.TOOL, new Dependencies());
    assertSame(neo4jLayout.databasesDirectory(), context.directory());
}
Also used : Dependencies(org.neo4j.collection.Dependencies) GlobalExtensionContext(org.neo4j.kernel.extension.context.GlobalExtensionContext) Test(org.junit.jupiter.api.Test)

Example 3 with GlobalExtensionContext

use of org.neo4j.kernel.extension.context.GlobalExtensionContext in project neo4j by neo4j.

the class ExtensionContextTest method shouldFindDependenciesFromHierarchyBottomUp.

@Test
void shouldFindDependenciesFromHierarchyBottomUp() {
    GlobalExtensionContext context = mock(GlobalExtensionContext.class);
    ExtensionFailureStrategy handler = mock(ExtensionFailureStrategy.class);
    Dependencies dependencies = new Dependencies();
    JobScheduler jobScheduler = mock(JobScheduler.class);
    dependencies.satisfyDependencies(jobScheduler);
    SubTestingExtensionFactory extensionFactory = new SubTestingExtensionFactory();
    GlobalExtensions extensions = new GlobalExtensions(context, iterable(extensionFactory), dependencies, handler);
    try (Lifespan ignored = new Lifespan(extensions)) {
        assertNotNull(dependencies.resolveDependency(TestingExtension.class));
    }
}
Also used : JobScheduler(org.neo4j.scheduler.JobScheduler) Dependencies(org.neo4j.collection.Dependencies) Lifespan(org.neo4j.kernel.lifecycle.Lifespan) GlobalExtensionContext(org.neo4j.kernel.extension.context.GlobalExtensionContext) Test(org.junit.jupiter.api.Test)

Example 4 with GlobalExtensionContext

use of org.neo4j.kernel.extension.context.GlobalExtensionContext in project neo4j by neo4j.

the class ExtensionContextTest method shouldConsultUnsatisfiedDependencyHandlerOnFailingDependencyClasses.

@Test
void shouldConsultUnsatisfiedDependencyHandlerOnFailingDependencyClasses() {
    GlobalExtensionContext context = mock(GlobalExtensionContext.class);
    ExtensionFailureStrategy handler = mock(ExtensionFailureStrategy.class);
    // that hasn't got anything.
    Dependencies dependencies = new Dependencies();
    UninitializableExtensionFactory extensionFactory = new UninitializableExtensionFactory();
    GlobalExtensions extensions = new GlobalExtensions(context, iterable(extensionFactory), dependencies, handler);
    try (Lifespan ignored = new Lifespan(extensions)) {
        verify(handler).handle(eq(extensionFactory), any(IllegalArgumentException.class));
    }
}
Also used : Dependencies(org.neo4j.collection.Dependencies) Lifespan(org.neo4j.kernel.lifecycle.Lifespan) GlobalExtensionContext(org.neo4j.kernel.extension.context.GlobalExtensionContext) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)4 Dependencies (org.neo4j.collection.Dependencies)4 GlobalExtensionContext (org.neo4j.kernel.extension.context.GlobalExtensionContext)4 Lifespan (org.neo4j.kernel.lifecycle.Lifespan)3 UnsatisfiedDependencyException (org.neo4j.exceptions.UnsatisfiedDependencyException)1 JobScheduler (org.neo4j.scheduler.JobScheduler)1