Context { private void init() { if(eventService == null) { eventService = EventServiceFactory.getInstance().getEventService(); } if(dbConnection == null) { dbConnection = new DSpace().getSingletonService(DBConnection.class); if(dbConnection == null) { DatabaseSchemaValidator schemaValidator = new DSpace().getSingletonService(DatabaseSchemaValidator.class); String validationError = schemaValidator == null ? "null" : schemaValidator.getDatabaseSchemaValidationError(); String message = "The schema validator returned: " + validationError; log.fatal("Cannot obtain the bean which provides a database connection. " + "Check previous entries in the dspace.log to find why the db failed to initialize. " + message); throw new DatabaseSchemaValidationException(message); } } currentUser = null; currentLocale = I18nUtil.DEFAULTLOCALE; extraLogInfo = ""; ignoreAuth = false; specialGroups = new ArrayList<>(); authStateChangeHistory = new Stack<Boolean>(); authStateClassCallHistory = new Stack<String>(); setMode(this.mode); } protected  Context(EventService eventService, DBConnection dbConnection);  Context();  Context(Mode mode); DatabaseConfigVO getDBConfig(); String getDbType(); void setCurrentUser(EPerson user); EPerson getCurrentUser(); Locale getCurrentLocale(); void setCurrentLocale(Locale locale); boolean ignoreAuthorization(); void turnOffAuthorisationSystem(); void restoreAuthSystemState(); void setExtraLogInfo(String info); String getExtraLogInfo(); void complete(); void commit(); void dispatchEvents(); void setDispatcher(String dispatcher); void addEvent(Event event); LinkedList<Event> getEvents(); boolean hasEvents(); Event pollEvent(); void abort(); boolean isValid(); boolean isReadOnly(); void setSpecialGroup(UUID groupID); boolean inSpecialGroup(UUID groupID); List<Group> getSpecialGroups(); void shutDownDatabase(); long getCacheSize(); void setMode(Mode newMode); Mode getCurrentMode(); @Deprecated void enableBatchMode(boolean batchModeEnabled); @Deprecated boolean isBatchModeEnabled(); @SuppressWarnings("unchecked") E reloadEntity(E entity); @SuppressWarnings("unchecked") void uncacheEntity(E entity); Boolean getCachedAuthorizationResult(DSpaceObject dspaceObject, int action, EPerson eperson); void cacheAuthorizedAction(DSpaceObject dspaceObject, int action, EPerson eperson, Boolean result, ResourcePolicy rp); Boolean getCachedGroupMembership(Group group, EPerson eperson); void cacheGroupMembership(Group group, EPerson eperson, Boolean isMember); void cacheAllMemberGroupsSet(EPerson ePerson, Set<Group> groups); Set<Group> getCachedAllMemberGroupsSet(EPerson ePerson);  }
@Test public void testSchemaValidation() throws SQLException { try { destroy(); destroyKernel(); initKernel(); init(); fail(); } catch(DatabaseSchemaValidationException ex) { assertTrue(StringUtils.isNotBlank(ex.getMessage())); assertTrue(StringUtils.contains(ex.getMessage(), "Missing table")); } finally { destroy(); destroyKernel(); initKernel(); initDatabase(); init(); } }