incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r1486660 - in /sling/whiteboard/bdelacretaz/sling-junit-launchpad: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/sling/ src/main/java/org/apache/sling/junit/ src/main/java/org/apache/...
Date Mon, 27 May 2013 16:33:41 GMT
Author: bdelacretaz
Date: Mon May 27 16:33:41 2013
New Revision: 1486660

URL: http://svn.apache.org/r1486660
Log:
sling-junit-launchpad prototype

Added:
    sling/whiteboard/bdelacretaz/sling-junit-launchpad/   (with props)
    sling/whiteboard/bdelacretaz/sling-junit-launchpad/pom.xml
    sling/whiteboard/bdelacretaz/sling-junit-launchpad/src/
    sling/whiteboard/bdelacretaz/sling-junit-launchpad/src/main/
    sling/whiteboard/bdelacretaz/sling-junit-launchpad/src/main/java/
    sling/whiteboard/bdelacretaz/sling-junit-launchpad/src/main/java/org/
    sling/whiteboard/bdelacretaz/sling-junit-launchpad/src/main/java/org/apache/
    sling/whiteboard/bdelacretaz/sling-junit-launchpad/src/main/java/org/apache/sling/
    sling/whiteboard/bdelacretaz/sling-junit-launchpad/src/main/java/org/apache/sling/junit/
    sling/whiteboard/bdelacretaz/sling-junit-launchpad/src/main/java/org/apache/sling/junit/launchpad/
    sling/whiteboard/bdelacretaz/sling-junit-launchpad/src/main/java/org/apache/sling/junit/launchpad/rules/
    sling/whiteboard/bdelacretaz/sling-junit-launchpad/src/main/java/org/apache/sling/junit/launchpad/rules/SlingLaunchpadRule.java
    sling/whiteboard/bdelacretaz/sling-junit-launchpad/src/test/
    sling/whiteboard/bdelacretaz/sling-junit-launchpad/src/test/java/
    sling/whiteboard/bdelacretaz/sling-junit-launchpad/src/test/java/org/
    sling/whiteboard/bdelacretaz/sling-junit-launchpad/src/test/java/org/apache/
    sling/whiteboard/bdelacretaz/sling-junit-launchpad/src/test/java/org/apache/sling/
    sling/whiteboard/bdelacretaz/sling-junit-launchpad/src/test/java/org/apache/sling/junit/
    sling/whiteboard/bdelacretaz/sling-junit-launchpad/src/test/java/org/apache/sling/junit/launchpad/
    sling/whiteboard/bdelacretaz/sling-junit-launchpad/src/test/java/org/apache/sling/junit/launchpad/rules/
    sling/whiteboard/bdelacretaz/sling-junit-launchpad/src/test/java/org/apache/sling/junit/launchpad/rules/SimplestSlingTestEverTest.java

Propchange: sling/whiteboard/bdelacretaz/sling-junit-launchpad/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon May 27 16:33:41 2013
@@ -0,0 +1,13 @@
+target
+bin
+*.iml
+*.ipr
+*.iws
+.settings
+.project
+.classpath
+.externalToolBuilders
+maven-eclipse.xml
+derby.log
+jackrabbit
+sling

Added: sling/whiteboard/bdelacretaz/sling-junit-launchpad/pom.xml
URL: http://svn.apache.org/viewvc/sling/whiteboard/bdelacretaz/sling-junit-launchpad/pom.xml?rev=1486660&view=auto
==============================================================================
--- sling/whiteboard/bdelacretaz/sling-junit-launchpad/pom.xml (added)
+++ sling/whiteboard/bdelacretaz/sling-junit-launchpad/pom.xml Mon May 27 16:33:41 2013
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.apache.sling</groupId>
+    <artifactId>sling</artifactId>
+    <version>16</version>
+  </parent>
+  <groupId>org.apache.sling</groupId>
+  <artifactId>org.apache.sling.junit.launchpad</artifactId>
+  <version>0.9.9-SNAPSHOT</version>
+  <packaging>jar</packaging>
+  <name>Apache Sling Launchpad Rule for JUnit</name>
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.sling</groupId>
+      <artifactId>org.apache.sling.launchpad</artifactId>
+      <version>7-SNAPSHOT</version>
+      <classifier>standalone</classifier>
+    </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-simple</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.sling</groupId>
+      <artifactId>org.apache.sling.testing.tools</artifactId>
+      <version>1.0.6</version>
+      <scope>compile</scope>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>compile</scope>
+    </dependency>
+  </dependencies>
+</project>

Added: sling/whiteboard/bdelacretaz/sling-junit-launchpad/src/main/java/org/apache/sling/junit/launchpad/rules/SlingLaunchpadRule.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/bdelacretaz/sling-junit-launchpad/src/main/java/org/apache/sling/junit/launchpad/rules/SlingLaunchpadRule.java?rev=1486660&view=auto
==============================================================================
--- sling/whiteboard/bdelacretaz/sling-junit-launchpad/src/main/java/org/apache/sling/junit/launchpad/rules/SlingLaunchpadRule.java
(added)
+++ sling/whiteboard/bdelacretaz/sling-junit-launchpad/src/main/java/org/apache/sling/junit/launchpad/rules/SlingLaunchpadRule.java
Mon May 27 16:33:41 2013
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.junit.launchpad.rules;
+
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.sling.launchpad.app.Main;
+import org.apache.sling.testing.tools.http.RequestBuilder;
+import org.apache.sling.testing.tools.http.RequestExecutor;
+import org.junit.rules.ExternalResource;
+import org.junit.runner.Description;
+import org.junit.runners.model.Statement;
+
+public class SlingLaunchpadRule extends ExternalResource {
+
+    private final int port;
+
+    // TODO this makes the Rule dependent on the Sling testing tools -
+    // we might want to move this to a sub-rule to avoid requiring them
+    private static RequestBuilder requestBuilder;
+    private static RequestExecutor requestExecutor;
+    public static final String ADMIN = "admin";
+    
+    public SlingLaunchpadRule() {
+        // TODO use dynamic free port
+        this.port = 9362;
+    }
+    
+    public int getPort() {
+        return port;
+    }
+    
+    @Override
+    public Statement apply(Statement base, Description description) {
+        // Could take config options from description.getTestClass...
+        return super.apply(base, description);
+    }
+
+    @Override
+    protected void before() throws Throwable {
+        // TODO for now we start Sling only once per VM, should be configurable.
+        // TODO cleanup remains of old Sling instances?
+        if(requestBuilder == null) {
+            final String [] args = { "-p", String.valueOf(port) };
+            Main.main(args);
+            requestExecutor = new RequestExecutor(new DefaultHttpClient());
+            requestBuilder = new RequestBuilder("http://127.0.0.1:" + port);
+        }
+    }
+
+    @Override
+    protected void after() {
+        // Nothing to do, Sling is stopped by a shutdown hook
+    }
+    
+    public RequestBuilder builder() {
+        return requestBuilder;
+    }
+    
+    public RequestExecutor executor() {
+        return requestExecutor;
+    }
+}

Added: sling/whiteboard/bdelacretaz/sling-junit-launchpad/src/test/java/org/apache/sling/junit/launchpad/rules/SimplestSlingTestEverTest.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/bdelacretaz/sling-junit-launchpad/src/test/java/org/apache/sling/junit/launchpad/rules/SimplestSlingTestEverTest.java?rev=1486660&view=auto
==============================================================================
--- sling/whiteboard/bdelacretaz/sling-junit-launchpad/src/test/java/org/apache/sling/junit/launchpad/rules/SimplestSlingTestEverTest.java
(added)
+++ sling/whiteboard/bdelacretaz/sling-junit-launchpad/src/test/java/org/apache/sling/junit/launchpad/rules/SimplestSlingTestEverTest.java
Mon May 27 16:33:41 2013
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.junit.launchpad.rules;
+
+import static org.apache.sling.junit.launchpad.rules.SlingLaunchpadRule.ADMIN;
+import org.junit.Rule;
+import org.junit.Test;
+
+/** Run some Sling tests via its HTTP interface - a full Sling launchpad
+ *  instance is setup transparently using a JUnit Rule.
+ */
+public class SimplestSlingTestEverTest {
+
+    @Rule
+    public final SlingLaunchpadRule sling = new SlingLaunchpadRule();
+
+    @Test
+    public void testOsgiConsole() throws Exception {
+        final String [] subpaths = {
+                "bundles",
+                "components",
+                "configMgr",
+                "config",
+                "licenses",
+                "logs",
+                "memoryusage",
+                "services"
+        };
+        
+        for(String subpath : subpaths) {
+            final String path = "/system/console/" + subpath;
+            sling.executor().execute(
+                sling.builder().buildGetRequest(path)
+                .withCredentials(ADMIN, ADMIN)
+            ).assertStatus(200);
+        }
+    }
+    
+    @Test
+    public void testRootContent() throws Exception {
+        sling.executor().execute(
+             sling.builder().buildGetRequest("/")
+            .withCredentials(ADMIN, ADMIN)
+        ).assertStatus(200)
+        .assertContentRegexp("[Ss]ling [Ll]aunchpad");
+    }
+}
\ No newline at end of file



Mime
View raw message