incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r1075819 - in /sling/trunk/testing: samples/integration-tests/ samples/integration-tests/src/test/java/org/apache/sling/testing/samples/testtools/ tools/ tools/src/main/java/org/apache/sling/testing/tools/osgi/
Date Tue, 01 Mar 2011 13:42:45 GMT
Author: bdelacretaz
Date: Tue Mar  1 13:42:45 2011
New Revision: 1075819

URL: http://svn.apache.org/viewvc?rev=1075819&view=rev
Log:
SLING-1963 - factor out WebconsoleClient

Added:
    sling/trunk/testing/tools/src/main/java/org/apache/sling/testing/tools/osgi/
    sling/trunk/testing/tools/src/main/java/org/apache/sling/testing/tools/osgi/WebconsoleClient.java
  (with props)
Modified:
    sling/trunk/testing/samples/integration-tests/pom.xml
    sling/trunk/testing/samples/integration-tests/src/test/java/org/apache/sling/testing/samples/testtools/SlingTestBase.java
    sling/trunk/testing/tools/pom.xml

Modified: sling/trunk/testing/samples/integration-tests/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/testing/samples/integration-tests/pom.xml?rev=1075819&r1=1075818&r2=1075819&view=diff
==============================================================================
--- sling/trunk/testing/samples/integration-tests/pom.xml (original)
+++ sling/trunk/testing/samples/integration-tests/pom.xml Tue Mar  1 13:42:45 2011
@@ -238,11 +238,6 @@
             <version>6-SNAPSHOT</version>
         </dependency>
         <dependency>
-            <groupId>org.apache.httpcomponents</groupId>
-            <artifactId>httpmime</artifactId>
-            <version>4.0.1</version>
-        </dependency>
-        <dependency>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-api</artifactId>
             <version>1.5.11</version>

Modified: sling/trunk/testing/samples/integration-tests/src/test/java/org/apache/sling/testing/samples/testtools/SlingTestBase.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/samples/integration-tests/src/test/java/org/apache/sling/testing/samples/testtools/SlingTestBase.java?rev=1075819&r1=1075818&r2=1075819&view=diff
==============================================================================
--- sling/trunk/testing/samples/integration-tests/src/test/java/org/apache/sling/testing/samples/testtools/SlingTestBase.java
(original)
+++ sling/trunk/testing/samples/integration-tests/src/test/java/org/apache/sling/testing/samples/testtools/SlingTestBase.java
Tue Mar  1 13:42:45 2011
@@ -24,14 +24,12 @@ import java.util.Collections;
 import java.util.List;
 import java.util.TreeSet;
 
-import org.apache.http.entity.mime.MultipartEntity;
-import org.apache.http.entity.mime.content.FileBody;
-import org.apache.http.entity.mime.content.StringBody;
 import org.apache.http.impl.client.DefaultHttpClient;
 import org.apache.sling.junit.TimeoutsProvider;
 import org.apache.sling.testing.tools.http.RequestBuilder;
 import org.apache.sling.testing.tools.http.RequestExecutor;
 import org.apache.sling.testing.tools.jarexec.JarExecutor;
+import org.apache.sling.testing.tools.osgi.WebconsoleClient;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -51,7 +49,7 @@ public class SlingTestBase {
     protected static RequestBuilder builder;
     protected static DefaultHttpClient httpClient = new DefaultHttpClient();
     protected static RequestExecutor executor = new RequestExecutor(httpClient);
-    
+    protected static WebconsoleClient webconsoleClient;
     private static boolean serverStarted;
     private static boolean serverStartedByThisClass;
     private static boolean serverReady;
@@ -88,6 +86,7 @@ public class SlingTestBase {
         
         serverStarted = true;
         builder = new RequestBuilder(serverBaseUrl);
+        webconsoleClient = new WebconsoleClient(executor, builder, ADMIN, ADMIN);
     }
     
     /** Optionally block here so that the runnable jar stays up - we can 
@@ -230,7 +229,7 @@ public class SlingTestBase {
             final String filenamePrefix = System.getProperty(key);
             for(String bundleFilename : bundleNames) {
                 if(bundleFilename.startsWith(filenamePrefix)) {
-                    installBundle(new File(dir, bundleFilename));
+                    webconsoleClient.installBundle(new File(dir, bundleFilename), true);
                     count++;
                 }
             }
@@ -239,25 +238,6 @@ public class SlingTestBase {
         log.info("{} additional bundles installed from {}", count, dir.getAbsolutePath());
     }
  
-    /** Install a bundle using the Felix webconsole HTTP interface */
-    protected void installBundle(File f) throws Exception {
-        log.info("Installing additional bundle {}", f.getName());
-        
-        // Setup request for Felix Webconsole bundle install
-        final MultipartEntity entity = new MultipartEntity();
-        entity.addPart("action",new StringBody("install"));
-        entity.addPart("bundlestart", new StringBody("true"));
-        entity.addPart("bundlefile", new FileBody(f));
-        
-        // Console returns a 302 on success (and in a POST this
-        // is not handled automatically as per HTTP spec)
-        executor.execute(
-                builder.buildPostRequest("/system/console/bundles")
-                .withCredentials(ADMIN, ADMIN)
-                .withEntity(entity)
-        ).assertStatus(302);
-    }
-    
     protected boolean isServerStartedByThisClass() {
         return serverStartedByThisClass;
     }

Modified: sling/trunk/testing/tools/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/testing/tools/pom.xml?rev=1075819&r1=1075818&r2=1075819&view=diff
==============================================================================
--- sling/trunk/testing/tools/pom.xml (original)
+++ sling/trunk/testing/tools/pom.xml Tue Mar  1 13:42:45 2011
@@ -63,6 +63,11 @@
             <version>4.0.1</version>
         </dependency>
         <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpmime</artifactId>
+            <version>4.0.1</version>
+        </dependency>
+        <dependency>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-api</artifactId>
             <version>1.5.11</version>

Added: sling/trunk/testing/tools/src/main/java/org/apache/sling/testing/tools/osgi/WebconsoleClient.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/tools/src/main/java/org/apache/sling/testing/tools/osgi/WebconsoleClient.java?rev=1075819&view=auto
==============================================================================
--- sling/trunk/testing/tools/src/main/java/org/apache/sling/testing/tools/osgi/WebconsoleClient.java
(added)
+++ sling/trunk/testing/tools/src/main/java/org/apache/sling/testing/tools/osgi/WebconsoleClient.java
Tue Mar  1 13:42:45 2011
@@ -0,0 +1,64 @@
+/*
+ * 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.testing.tools.osgi;
+
+import java.io.File;
+
+import org.apache.http.entity.mime.MultipartEntity;
+import org.apache.http.entity.mime.content.FileBody;
+import org.apache.http.entity.mime.content.StringBody;
+import org.apache.sling.testing.tools.http.RequestBuilder;
+import org.apache.sling.testing.tools.http.RequestExecutor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/** HTTP Client for the Felix webconsole - simplistic for now */
+public class WebconsoleClient {
+    private final Logger log = LoggerFactory.getLogger(getClass());
+    private final RequestExecutor executor;
+    private final RequestBuilder builder;
+    private final String username;
+    private final String password;
+    
+    public WebconsoleClient(RequestExecutor executor, RequestBuilder builder, String username,
String password) {
+        this.executor = executor;
+        this.builder = builder;
+        this.username = username;
+        this.password = password;
+    }
+    
+    /** Install a bundle using the Felix webconsole HTTP interface */
+    public void installBundle(File f, boolean startBundle) throws Exception {
+        log.info("Installing additional bundle {}", f.getName());
+        
+        // Setup request for Felix Webconsole bundle install
+        final MultipartEntity entity = new MultipartEntity();
+        entity.addPart("action",new StringBody("install"));
+        if(startBundle) {
+            entity.addPart("bundlestart", new StringBody("true"));
+        }
+        entity.addPart("bundlefile", new FileBody(f));
+        
+        // Console returns a 302 on success (and in a POST this
+        // is not handled automatically as per HTTP spec)
+        executor.execute(
+                builder.buildPostRequest("/system/console/bundles")
+                .withCredentials(username, password)
+                .withEntity(entity)
+        ).assertStatus(302);
+    }
+}

Propchange: sling/trunk/testing/tools/src/main/java/org/apache/sling/testing/tools/osgi/WebconsoleClient.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/trunk/testing/tools/src/main/java/org/apache/sling/testing/tools/osgi/WebconsoleClient.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL



Mime
View raw message