Project

General

Profile

« Previous | Next » 

Revision 87eea6d6

Added by Andreas Kohlbecker over 3 years ago

ref #9188 more robust and efficient DrushExecuter

View differences:

src/main/java/eu/etaxonomy/dataportal/junit/CdmDataPortalTestBase.java
21 21
import eu.etaxonomy.dataportal.DrupalVars;
22 22
import eu.etaxonomy.dataportal.selenium.WebDriverFactory;
23 23
import eu.etaxonomy.drush.DrushExecuter;
24
import eu.etaxonomy.drush.DrushExecutionFailure;
24 25

  
25 26
/**
26 27
 * @author a.kohlbecker
......
71 72
	}
72 73

  
73 74
	@After
74
    public void resetToOriginalState() throws IOException, InterruptedException {
75
    public void resetToOriginalState() throws IOException, InterruptedException, DrushExecutionFailure {
75 76
        restoreOriginalVars();
76 77
    }
77 78

  
......
86 87
     *
87 88
     * @throws IOException
88 89
     * @throws InterruptedException
90
     * @throws DrushExecutionFailure
89 91
     */
90
    protected void setDrupalVar(String varKey, String varValue) throws IOException, InterruptedException {
92
    protected void setDrupalVar(String varKey, String varValue) throws IOException, InterruptedException, DrushExecutionFailure {
91 93
        DrushExecuter dex = getContext().drushExecuter();
92 94
        List<Object> result = dex.execute(DrushExecuter.variableGet, varKey);
93 95
        assertEquals(1, result.size());
......
96 98
            drupalVarsBeforeTest.put(varKey, result.get(0));
97 99
        }
98 100
        result = dex.execute(DrushExecuter.variableSet, varKey, varValue);
99
        assertEquals("success", result.get(1));
100 101
    }
101 102

  
102
    protected void restoreOriginalVars() throws IOException, InterruptedException {
103
    protected void restoreOriginalVars() throws IOException, InterruptedException, DrushExecutionFailure {
103 104
        DrushExecuter dex = getContext().drushExecuter();
104 105
        boolean fail = false;
105 106
        for(String varKey : drupalVarsBeforeTest.keySet()) {
106 107
            try {
107 108
                List<Object> result = dex.execute(DrushExecuter.variableSet, varKey, drupalVarsBeforeTest.get(varKey).toString());
108
                assertEquals("success", result.get(1));
109 109
            } catch (Exception e) {
110 110
                logger.error("FATAL ERROR: Restoring the original drupal variable " + varKey + " = " + drupalVarsBeforeTest.get(varKey) + " failed.", e);
111 111
                fail = true;

Also available in: Unified diff