This is an automated email from the ASF dual-hosted git repository. rombert pushed a commit to annotated tag org.apache.sling.crankstart.launcher-1.0.0 in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-crankstart-launcher.git
commit d1e55079739d3319af5d5769fcdbaf0dcdb69a83 Author: Bertrand Delacretaz <[email protected]> AuthorDate: Thu Jul 31 15:32:42 2014 +0000 Add support for bundle start levels, and move default values to CrankstartContext git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/crankstart/launcher@1614923 13f79535-47bb-0310-9956-ffa450edef68 --- pom.xml | 6 ++++ .../launcher/CrankstartBootstrapTest.java | 39 ++++++++++++++++++++++ src/test/resources/launcher-test.crank.txt | 5 +++ 3 files changed, 50 insertions(+) diff --git a/pom.xml b/pom.xml index e1136e1..a91660d 100644 --- a/pom.xml +++ b/pom.xml @@ -152,6 +152,12 @@ <scope>test</scope> </dependency> <dependency> + <groupId>org.apache.sling</groupId> + <artifactId>org.apache.sling.commons.json</artifactId> + <version>2.0.6</version> + <scope>test</scope> + </dependency> + <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpclient</artifactId> <version>4.1</version> diff --git a/src/test/java/org/apache/sling/crankstart/launcher/CrankstartBootstrapTest.java b/src/test/java/org/apache/sling/crankstart/launcher/CrankstartBootstrapTest.java index f5c8547..71a7aa4 100644 --- a/src/test/java/org/apache/sling/crankstart/launcher/CrankstartBootstrapTest.java +++ b/src/test/java/org/apache/sling/crankstart/launcher/CrankstartBootstrapTest.java @@ -22,6 +22,8 @@ import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpUriRequest; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.util.EntityUtils; +import org.apache.sling.commons.json.JSONArray; +import org.apache.sling.commons.json.JSONObject; import org.apache.sling.commons.testing.junit.Retry; import org.apache.sling.commons.testing.junit.RetryRule; import org.junit.AfterClass; @@ -242,6 +244,43 @@ public class CrankstartBootstrapTest { } } + @Test + @Retry(timeoutMsec=10000, intervalMsec=250) + public void testSpecificStartLevel() throws Exception { + // Verify that this bundle is only installed, as it's set to start level 99 + setAdminCredentials(); + final String path = "/system/console/bundles/org.apache.commons.collections.json"; + final HttpUriRequest get = new HttpGet(baseUrl + path); + HttpResponse response = null; + try { + response = client.execute(get); + assertEquals("Expecting bundle status to be available at " + get.getURI(), 200, response.getStatusLine().getStatusCode()); + assertNotNull("Expecting response entity", response.getEntity()); + String encoding = "UTF-8"; + if(response.getEntity().getContentEncoding() != null) { + encoding = response.getEntity().getContentEncoding().getValue(); + } + final String content = IOUtils.toString(response.getEntity().getContent(), encoding); + + // Start level is in the props array, with key="Start Level" + final JSONObject status = new JSONObject(content); + final JSONArray props = status.getJSONArray("data").getJSONObject(0).getJSONArray("props"); + final String KEY = "key"; + final String SL = "Start Level"; + boolean found = false; + for(int i=0; i < props.length(); i++) { + final JSONObject o = props.getJSONObject(i); + if(o.has(KEY) && SL.equals(o.getString(KEY))) { + found = true; + assertEquals("Expecting the start level that we set", "99", o.getString("value")); + } + } + assertTrue("Expecting start level to be found in JSON output", found); + } finally { + closeConnection(response); + } + } + private static String getOsgiStoragePath() { final File tmpRoot = new File(System.getProperty("java.io.tmpdir")); final Random random = new Random(); diff --git a/src/test/resources/launcher-test.crank.txt b/src/test/resources/launcher-test.crank.txt index 54b5461..179d4dd 100644 --- a/src/test/resources/launcher-test.crank.txt +++ b/src/test/resources/launcher-test.crank.txt @@ -42,6 +42,11 @@ bundle mvn:org.apache.sling/org.apache.sling.jcr.jcr-wrapper/2.0.0 bundle mvn:org.apache.sling/org.apache.sling.crankstart.sling.extensions/0.0.1-SNAPSHOT bundle mvn:commons-io/commons-io/2.4 +# Install a bundle at a start level higher than the current one +# to be able to check that it's not active +defaults crankstart.bundle.start.level 99 +bundle mvn:commons-collections/commons-collections/3.2.1 + # Now start our bundles start.all.bundles -- To stop receiving notification emails like this one, please contact "[email protected]" <[email protected]>.
