Author: bdelacretaz
Date: Wed Jul 8 14:35:30 2009
New Revision: 792164
URL: http://svn.apache.org/viewvc?rev=792164&view=rev
Log:
SLING-1037 - test overriding /libs configs with /apps
Modified:
sling/trunk/contrib/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/jcrinstall/SimpleConfigTest.java
Modified:
sling/trunk/contrib/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/jcrinstall/SimpleConfigTest.java
URL:
http://svn.apache.org/viewvc/sling/trunk/contrib/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/jcrinstall/SimpleConfigTest.java?rev=792164&r1=792163&r2=792164&view=diff
==============================================================================
---
sling/trunk/contrib/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/jcrinstall/SimpleConfigTest.java
(original)
+++
sling/trunk/contrib/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/jcrinstall/SimpleConfigTest.java
Wed Jul 8 14:35:30 2009
@@ -27,6 +27,9 @@
*/
public class SimpleConfigTest extends JcrinstallTestBase {
+ static final String CONFIG_URL = HTTP_BASE_URL +
"/system/console/config";
+ static final int timeoutSeconds = 4;
+
static class ConfigCondition implements
JcrinstallTestBase.StringCondition {
private final String expectedValue;
private final boolean expectValueInContent;
@@ -41,44 +44,77 @@
}
};
+ protected String createConfig(String configPid, Map<String, String>
properties) throws IOException {
+ return createConfig("/apps", configPid, properties);
+ }
+
+ protected String createConfig(String basePath, String configPid,
Map<String, String> properties) throws IOException {
+ final String configPath = basePath + "/" +
getClass().getSimpleName() + "/install";
+ testClient.mkdirs(HTTP_BASE_URL, configPath);
+ properties.put("jcr:primaryType", "sling:OsgiConfig");
+ return testClient.createNode(HTTP_BASE_URL + configPath + "/" +
configPid, properties);
+ }
+
public void testSimpleConfig() throws IOException {
- final String uniqueId = getClass().getName() +
System.currentTimeMillis();
+ final String uniqueId = getClass().getName() + ".A." +
System.currentTimeMillis();
final String key = getClass().getName() + ".key";
final String value = getClass().getName() + "." + uniqueId;
final String keyValue = key + "=" + value;
- final String configUrl = HTTP_BASE_URL +
"/system/console/config";
final String contentType = CONTENT_TYPE_HTML;
- final int timeoutSeconds = 4;
- assertContentWithTimeout("Before test, config must not exist",
configUrl,
+ assertContentWithTimeout("Before test, config must not exist",
CONFIG_URL,
contentType, new ConfigCondition(keyValue,
false), timeoutSeconds);
// Create an OSGi config using a sling:OsgiConfig node
- final String configPath = "/apps/" + getClass().getSimpleName()
+ "/install";
- testClient.mkdirs(HTTP_BASE_URL, configPath);
- final Map<String, String> nodeProperties = new HashMap<String,
String>();
- nodeProperties.put("jcr:primaryType", "sling:OsgiConfig");
- nodeProperties.put(key, value);
- final String toDelete = testClient.createNode(HTTP_BASE_URL +
configPath + "/" + uniqueId, nodeProperties);
- assertContentWithTimeout("Config must be present after creating
config node", configUrl,
+ final Map<String, String> props = new HashMap<String, String>();
+ props.put(key, value);
+ final String toDelete = createConfig(uniqueId, props);
+ assertContentWithTimeout("Config must be present after creating
config node", CONFIG_URL,
contentType, new ConfigCondition(keyValue,
true), timeoutSeconds);
// Update config node, verify that config is updated
final String newValue = getClass().getName() + ".NEW." +
System.currentTimeMillis();
final String newKeyValue = key + "=" + newValue;
- nodeProperties.put(key, newValue);
- testClient.createNode(HTTP_BASE_URL + configPath + "/" +
uniqueId, nodeProperties);
- assertContentWithTimeout("Config must be modified after node
update", configUrl,
+ props.put(key, newValue);
+ createConfig(uniqueId, props);
+ assertContentWithTimeout("Config must be modified after node
update", CONFIG_URL,
contentType, new ConfigCondition(newKeyValue,
true), timeoutSeconds);
- assertContentWithTimeout("Old value must be gone after update",
configUrl,
+ assertContentWithTimeout("Old value must be gone after update",
CONFIG_URL,
contentType, new ConfigCondition(keyValue,
false), timeoutSeconds);
// Delete and verify that the config is gone
testClient.delete(toDelete);
- assertContentWithTimeout("Old config must be gone after
removing config node", configUrl,
+ assertContentWithTimeout("Old config must be gone after
removing config node", CONFIG_URL,
contentType, new ConfigCondition(keyValue,
false), timeoutSeconds);
- assertContentWithTimeout("New config must be gone after
removing config node", configUrl,
+ assertContentWithTimeout("New config must be gone after
removing config node", CONFIG_URL,
contentType, new ConfigCondition(newKeyValue,
false), timeoutSeconds);
}
+
+ public void testAppsOverridesLibs() throws IOException {
+ final String uniqueId = getClass().getName() + ".B." +
System.currentTimeMillis();
+ final Map<String, String> props = new HashMap<String, String>();
+ props.put("foo", "barONE");
+ final String toDeleteA = createConfig("/libs", uniqueId, props);
+ assertContentWithTimeout("Config must be present after creating
/libs config node", CONFIG_URL,
+ CONTENT_TYPE_HTML, new
ConfigCondition("barONE", true), timeoutSeconds);
+
+ props.put("foo", "barTWO");
+ final String toDeleteB = createConfig("/apps", uniqueId, props);
+ assertContentWithTimeout("Config must be updated after creating
/apps config node", CONFIG_URL,
+ CONTENT_TYPE_HTML, new
ConfigCondition("barTWO", true), timeoutSeconds);
+
+ props.put("foo", "barTHREE");
+ createConfig("/libs", uniqueId, props);
+ assertContentWithTimeout("Config must NOT be updated after
updating /libs config node", CONFIG_URL,
+ CONTENT_TYPE_HTML, new
ConfigCondition("barTWO", true), timeoutSeconds);
+
+ props.put("foo", "barFOUR");
+ createConfig("/apps", uniqueId, props);
+ assertContentWithTimeout("Config must be updated after updating
/apps config node", CONFIG_URL,
+ CONTENT_TYPE_HTML, new
ConfigCondition("barFOUR", true), timeoutSeconds);
+
+ testClient.delete(toDeleteA);
+ testClient.delete(toDeleteB);
+ }
}