@Test public void differentInstancesShouldHaveEqualHashCodesAndBeEqual() { KernelExtensionFactory<?> one = newInstance(); KernelExtensionFactory<?> two = newInstance(); assertEquals( "new instances have different hash codes", one.hashCode(), two.hashCode() ); assertEquals( "new instances are not equals", one, two ); one = loadInstance(); two = loadInstance(); assertEquals( "loaded instances have different hash codes", one.hashCode(), two.hashCode() ); assertEquals( "loaded instances are not equals", one, two ); one = loadInstance(); two = newInstance(); assertEquals( "loaded instance and new instance have different hash codes", one.hashCode(), two.hashCode() ); assertEquals( "loaded instance and new instance are not equals", one, two ); }
@Test public void extensionShouldHavePublicNoArgConstructor() { KernelExtensionFactory<?> instance = null; try { instance = newInstance(); } catch ( IllegalArgumentException failure ) { failure.printStackTrace(); fail( "Contract violation: extension class must have public no-arg constructor (Exception in stderr)" ); } assertNotNull( instance ); }
protected GraphDatabaseAPI graphDb( int instance ) { Map<String, String> config = configuration( instance ); return (GraphDatabaseAPI) new TestGraphDatabaseFactory().newImpermanentDatabaseBuilder().setConfig( config ).newGraphDatabase(); }
@Test public void shouldBeAbleToLoadExtensionAsAServiceProvider() { KernelExtensionFactory<?> instance = null; try { instance = loadInstance(); } catch ( ClassCastException failure ) { failure.printStackTrace(); fail( "Loaded instance does not match the extension class (Exception in stderr)" ); } assertNotNull( "Could not load the kernel extension with the provided key", instance ); assertSame( "Class of the loaded instance is a subclass of the extension class", instance.getClass(), extClass ); }