private void runRemainingPhases()

in src/main/java/org/apache/sling/testing/serversetup/ServerSetup.java [160:199]


    private void runRemainingPhases(boolean isStartup) throws Exception {
        final String mode = isStartup ? "startup" : "shutdown";
        
        // In startup mode, fail if any phases failed previously
        // (in shutdown mode it's probably safer to try to run cleanup phases)
        if(isStartup && !failedPhases.isEmpty()) {
            throw new SetupException("Some SetupPhases previously failed: " + failedPhases);
        }
        
        for(String id : phasesToRun) {
            final SetupPhase p = phases.get(id);
            
            if(donePhases.contains(id)) {
                log.debug("SetupPhase ({}) with id {} already ran, ignored", mode, id);
                continue;
            }
            
            if(p == null) {
                log.info("SetupPhase ({}) with id {} not found, ignored", mode, id);
                donePhases.add(id);
                continue;
            }
            
            if(p.isStartupPhase() == isStartup) {
                log.info("Executing {} phase: {}", mode, p); 
                try {
                    p.run(this);
                } catch(Exception e) {
                    failedPhases.add(id);
                    throw e;
                } catch (AssertionFailedError ae) {
                    // Some of our tools throw this, might not to avoid it in the future
                    failedPhases.add(id);
                    throw new Exception("AssertionFailedError in runRemainingPhases", ae);
                } finally {
                    donePhases.add(id);
                }
            }
        }
    }