public void addDescriptors(DatabaseSession session) { if (project == null) { if (getAdapter().isOriginalSetupRequired()) { try { // If called twice, method TestSystem.addDescriptors(Session) // may behave wrong during the second call // (typically because during the second call project value is no longer null, // which causes problems in case more than one project is used). // Therefore another instance of TestSystem is created - not to spoil the original. TestSystem tempTestSystem = getTestSystem().getClass().newInstance(); tempTestSystem.addDescriptors(session); try { tempTestSystem.createTables(session); } catch (Exception ex2) { throw new TestProblemException( "Exception thrown by " + Helper.getShortClassName(tempTestSystem) + ".createTables() ", ex2); } } catch (Exception ex1) { throw new TestProblemException( "Failed to create an instance of " + getTestSystem().getClass() + " ", ex1); } } // This trick stores all descriptors used by testSystem into project DatabaseSession dummyDatabaseSession = new Project((Login) session.getLogin().clone()).createDatabaseSession(); getTestSystem().addDescriptors(dummyDatabaseSession); project = dummyDatabaseSession.getProject(); getAdapter().updateProject(project, session); } (session).addDescriptors(project); afterAddDescriptors(session, getTestSystem()); }