Revision e69d6355
Added by Andreas Kohlbecker over 2 years ago
src/main/java/eu/etaxonomy/dataportal/junit/CdmDataPortalTestBase.java | ||
---|---|---|
91 | 91 |
protected void setDrupalVar(String varKey, String varValue) throws IOException, InterruptedException, DrushExecutionFailure { |
92 | 92 |
DrushExecuter dex = getContext().drushExecuter(); |
93 | 93 |
List<Object> result = dex.execute(DrushExecuter.variableGet, varKey); |
94 |
assertEquals(1, result.size());
|
|
95 |
if(!drupalVarsBeforeTest.containsKey(varKey)) { |
|
94 |
assertTrue(0 <= result.size() && result.size() <= 1);
|
|
95 |
if(result.size() == 1 && !drupalVarsBeforeTest.containsKey(varKey)) {
|
|
96 | 96 |
// stored original values must not be replaced |
97 | 97 |
drupalVarsBeforeTest.put(varKey, result.get(0)); |
98 | 98 |
} |
... | ... | |
102 | 102 |
protected void setDrupalVarJson(String varKey, String varValue) throws IOException, InterruptedException, DrushExecutionFailure { |
103 | 103 |
DrushExecuter dex = getContext().drushExecuter(); |
104 | 104 |
List<Object> result = dex.execute(DrushExecuter.variableGet, varKey); |
105 |
assertEquals(1, result.size());
|
|
106 |
if(!drupalVarsBeforeTest.containsKey(varKey)) { |
|
105 |
assertTrue(0 <= result.size() && result.size() <= 1);
|
|
106 |
if(result.size() == 1 && !drupalVarsBeforeTest.containsKey(varKey)) {
|
|
107 | 107 |
// stored original values must not be replaced |
108 | 108 |
drupalVarsBeforeTest.put(varKey, result.get(0)); |
109 |
} else { |
|
110 |
// empty value will unset |
|
111 |
drupalVarsBeforeTest.put(varKey, ""); |
|
109 | 112 |
} |
110 | 113 |
result = dex.execute(DrushExecuter.variableSetJson, varKey, varValue); |
111 | 114 |
} |
... | ... | |
115 | 118 |
boolean fail = false; |
116 | 119 |
for(String varKey : drupalVarsBeforeTest.keySet()) { |
117 | 120 |
try { |
118 |
List<Object> result = dex.execute(DrushExecuter.variableSet, varKey, drupalVarsBeforeTest.get(varKey).toString()); |
|
121 |
List<Object> result = dex.execute(DrushExecuter.variableSetJson, varKey, drupalVarsBeforeTest.get(varKey).toString());
|
|
119 | 122 |
} catch (Exception e) { |
120 | 123 |
logger.error("FATAL ERROR: Restoring the original drupal variable " + varKey + " = " + drupalVarsBeforeTest.get(varKey) + " failed.", e); |
121 | 124 |
fail = true; |
Also available in: Unified diff
proper setting and reverting of all kinds of drupal variables