Author: ivol37 at gmail.com
Date: Fri Nov 19 15:12:36 2010
New Revision: 433

Log:
[AMDATU-184] Fixed some of the errors that appear during integration test 
execution.
-1- Refactored dependencies such that only relevant bundles are deployed.
-2- Fixed bug in HttpServiceTest with services being registered twice (causing 
the alias already in use exceptions)

Modified:
   trunk/integration-tests/pom.xml
   
trunk/integration-tests/src/test/java/org/amdatu/test/integration/base/IntegrationTestBase.java
   
trunk/integration-tests/src/test/java/org/amdatu/test/integration/tests/CassandraDaemonIntegrationTest.java
   
trunk/integration-tests/src/test/java/org/amdatu/test/integration/tests/CassandraPersistenceManagerTest.java
   
trunk/integration-tests/src/test/java/org/amdatu/test/integration/tests/GadgetManagementServiceTest.java
   
trunk/integration-tests/src/test/java/org/amdatu/test/integration/tests/HttpServiceTest.java
   
trunk/integration-tests/src/test/java/org/amdatu/test/integration/tests/TenantManagementServiceTest.java
   
trunk/integration-tests/src/test/java/org/amdatu/test/integration/tests/UserAdminStoreTest.java

Modified: trunk/integration-tests/pom.xml
==============================================================================
--- trunk/integration-tests/pom.xml     (original)
+++ trunk/integration-tests/pom.xml     Fri Nov 19 15:12:36 2010
@@ -13,81 +13,6 @@
   <name>Amdatu Integration Tests</name>
   <description>This bundle contains integration tests for the 
project</description>
 
-  <dependencyManagement>
-    <dependencies>
-      <dependency>
-        <groupId>org.amdatu.core</groupId>
-        <artifactId>tenant</artifactId>
-        <version>${platform.version}</version>
-        <scope>provided</scope>
-        <type>bundle</type>
-      </dependency>
-      <dependency>
-        <groupId>org.amdatu.core.config</groupId>
-        <artifactId>templates</artifactId>
-        <version>${platform.version}</version>
-        <scope>provided</scope>
-        <type>bundle</type>
-      </dependency>
-      <dependency>
-        <groupId>org.amdatu.core.config</groupId>
-        <artifactId>filebased</artifactId>
-        <version>${platform.version}</version>
-        <scope>provided</scope>
-        <type>bundle</type>
-      </dependency>
-      <dependency>
-        <groupId>org.amdatu.core.cassandra</groupId>
-        <artifactId>application</artifactId>
-        <version>${platform.version}</version>
-        <scope>provided</scope>
-        <type>bundle</type>
-      </dependency>
-      <dependency>
-        <groupId>org.amdatu.core.cassandra</groupId>
-        <artifactId>listener</artifactId>
-        <version>${platform.version}</version>
-        <scope>provided</scope>
-        <type>bundle</type>
-      </dependency>
-      <dependency>
-        <groupId>org.amdatu.core.cassandra</groupId>
-        <artifactId>persistencemanager</artifactId>
-        <version>${platform.version}</version>
-        <scope>provided</scope>
-        <type>bundle</type>
-      </dependency>
-      <dependency>
-        <groupId>org.amdatu.core.cassandra</groupId>
-        <artifactId>useradminstore</artifactId>
-        <version>${platform.version}</version>
-        <scope>provided</scope>
-        <type>bundle</type>
-      </dependency>
-      <dependency>
-        <groupId>org.amdatu.web</groupId>
-        <artifactId>httpcontext</artifactId>
-        <version>${platform.version}</version>
-        <scope>provided</scope>
-        <type>bundle</type>
-      </dependency>
-      <dependency>
-        <groupId>org.amdatu.web.rest</groupId>
-        <artifactId>wink</artifactId>
-        <version>${platform.version}</version>
-        <scope>provided</scope>
-        <type>bundle</type>
-      </dependency>
-      <dependency>
-        <groupId>org.amdatu.opensocial</groupId>
-        <artifactId>shindig</artifactId>
-        <version>${platform.version}</version>
-        <scope>provided</scope>
-        <type>bundle</type>
-      </dependency>    
-    </dependencies>
-  </dependencyManagement>
-
   <dependencies>
     <!-- Test scope dependencies -->
     <!-- This is required to be first so that pax-exam classloader is not 
messed up with a newer version of felix
@@ -125,18 +50,21 @@
     <dependency>
       <groupId>org.amdatu.core.config</groupId>
       <artifactId>filebased</artifactId>
+      <version>${platform.version}</version>
       <scope>test</scope>
       <type>bundle</type>
     </dependency>
     <dependency>
       <groupId>org.amdatu.web</groupId>
       <artifactId>httpcontext</artifactId>
+      <version>${platform.version}</version>      
       <scope>test</scope>
       <type>bundle</type>
     </dependency>
     <dependency>
       <groupId>org.amdatu.core.config</groupId>
       <artifactId>templates</artifactId>
+      <version>${platform.version}</version>      
       <scope>test</scope>
       <type>bundle</type>
     </dependency>
@@ -150,12 +78,14 @@
     <dependency>
       <groupId>org.amdatu.opensocial</groupId>
       <artifactId>shindig</artifactId>
+      <version>${platform.version}</version>      
       <scope>test</scope>
       <type>bundle</type>
     </dependency>
     <dependency>
       <groupId>org.amdatu.core</groupId>
       <artifactId>tenant</artifactId>
+      <version>${platform.version}</version>      
       <scope>test</scope>
       <type>bundle</type>
     </dependency>
@@ -169,18 +99,21 @@
     <dependency>
       <groupId>org.amdatu.core.cassandra</groupId>
       <artifactId>persistencemanager</artifactId>
+      <version>${platform.version}</version>      
       <scope>test</scope>
       <type>bundle</type>
     </dependency>
     <dependency>
       <groupId>org.amdatu.core.cassandra</groupId>
       <artifactId>listener</artifactId>
+      <version>${platform.version}</version>      
       <scope>test</scope>
       <type>bundle</type>
     </dependency>
     <dependency>
       <groupId>org.amdatu.core.cassandra</groupId>
       <artifactId>useradminstore</artifactId>
+      <version>${platform.version}</version>      
       <scope>test</scope>
       <type>bundle</type>
     </dependency>
@@ -194,6 +127,7 @@
     <dependency>
       <groupId>org.amdatu.web.rest</groupId>
       <artifactId>wink</artifactId>
+      <version>${platform.version}</version>      
       <scope>test</scope>
       <type>bundle</type>
     </dependency>
@@ -205,34 +139,27 @@
       <type>bundle</type>
     </dependency>
     <dependency>
-      <groupId>org.apache.felix</groupId>
-      <artifactId>org.apache.felix.http.bundle</artifactId>
-      <version>${org.apache.felix.http.version}</version>
+      <groupId>org.ops4j.pax.useradmin</groupId>
+      <artifactId>pax-useradmin-service</artifactId>
+      <version>${pax.useradmin.version}</version>
       <scope>test</scope>
       <type>bundle</type>
     </dependency>
     <dependency>
-      <groupId>commons-httpclient</groupId>
-      <artifactId>commons-httpclient</artifactId>
-      <version>3.1</version>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>commons-logging</groupId>
-      <artifactId>commons-logging</artifactId>
-      <version>1.1.1</version>
+      <groupId>org.amdatu.opensocial</groupId>
+      <artifactId>gadgetmanagement</artifactId>
+      <version>${platform.version}</version>
       <scope>test</scope>
+      <type>bundle</type>
     </dependency>
     <dependency>
-      <groupId>commons-codec</groupId>
-      <artifactId>commons-codec</artifactId>
-      <version>1.4</version>
+      <groupId>org.amdatu.authorization.login</groupId>
+      <artifactId>service</artifactId>
+      <version>${platform.version}</version>
       <scope>test</scope>
-    </dependency>
-
-    <!-- 
-      AMDATU-138 added this list to get things to work
-    -->
+      <type>bundle</type>
+    </dependency>  
+    
     <dependency>
       <groupId>org.apache.felix</groupId>
       <artifactId>org.apache.felix.framework</artifactId>
@@ -255,60 +182,68 @@
       <groupId>org.apache.felix</groupId>
       <artifactId>org.apache.felix.http.jetty</artifactId>
       <version>${org.apache.felix.http.version}</version>
-      <scope>provided</scope>
+      <scope>test</scope>
     </dependency>
     <dependency>
       <groupId>org.apache.felix</groupId>
       <artifactId>org.apache.felix.http.whiteboard</artifactId>
       <version>${org.apache.felix.http.version}</version>
-      <scope>provided</scope>
+      <scope>test</scope>
+    </dependency>    
+    <dependency>
+      <groupId>commons-httpclient</groupId>
+      <artifactId>commons-httpclient</artifactId>
+      <version>3.1</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>commons-logging</groupId>
+      <artifactId>commons-logging</artifactId>
+      <version>1.1.1</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>commons-codec</groupId>
+      <artifactId>commons-codec</artifactId>
+      <version>1.4</version>
+      <scope>test</scope>
     </dependency>
     <dependency>
       <groupId>org.ops4j.pax.swissbox</groupId>
       <artifactId>pax-swissbox-core</artifactId>
       <version>${pax.swissbox.version}</version>
-      <scope>provided</scope>
+      <scope>test</scope>
     </dependency>
     <dependency>
       <groupId>org.ops4j.base</groupId>
       <artifactId>ops4j-base-lang</artifactId>
       <version>1.2.2</version>
-      <scope>provided</scope>
+      <scope>test</scope>
     </dependency>
     <dependency>
       <groupId>org.apache.sling</groupId>
       <artifactId>org.apache.sling.commons.mime</artifactId>
       <version>${org.apache.sling.commons.mime.version}</version>
-      <scope>provided</scope>
+      <scope>test</scope>
     </dependency>
     <dependency>
       <groupId>org.apache.sling</groupId>
       <artifactId>org.apache.sling.commons.osgi</artifactId>
       <version>${org.apache.sling.commons.osgi.version}</version>
-      <scope>provided</scope>
+      <scope>test</scope>
     </dependency>
+   
+    
     <dependency>
-      <groupId>org.ops4j.pax.useradmin</groupId>
-      <artifactId>pax-useradmin-service</artifactId>
-      <version>${pax.useradmin.version}</version>
-      <scope>provided</scope>
+      <groupId>servletapi</groupId>
+      <artifactId>servletapi</artifactId>
+      <version>2.3</version>
+      <scope>test</scope>
     </dependency>
-      <dependency>
-        <groupId>org.amdatu.opensocial</groupId>
-        <artifactId>gadgetmanagement</artifactId>
-        <version>${platform.version}</version>
-        <scope>provided</scope>
-      </dependency>
-      <dependency>
-        <groupId>org.amdatu.authorization.login</groupId>
-        <artifactId>service</artifactId>
-        <version>${platform.version}</version>
-        <scope>provided</scope>
-      </dependency>  
+
   </dependencies>
 
   <build>
-
     <plugins>
       <plugin>
         <groupId>org.apache.felix</groupId>

Modified: 
trunk/integration-tests/src/test/java/org/amdatu/test/integration/base/IntegrationTestBase.java
==============================================================================
--- 
trunk/integration-tests/src/test/java/org/amdatu/test/integration/base/IntegrationTestBase.java
     (original)
+++ 
trunk/integration-tests/src/test/java/org/amdatu/test/integration/base/IntegrationTestBase.java
     Fri Nov 19 15:12:36 2010
@@ -70,7 +70,7 @@
      * This base-configure method includes all default options, and 
instantiates all of Amdatu
      */
     public Option[] configure() {
-        Option[] baseOptions = 
+        Option[] baseOptions =
             options(
                 mavenConfiguration(),
 
@@ -90,7 +90,7 @@
                     dependencyManager(),
                     configAdmin(),
                     felixLog(),
-                 
+
                     // Amdatu platform bundles
                     // TODO: this works fine when running 'mvn install' since 
the artifacts will then be deployed to the maven
                     // repository prior to running this integration test. With 
'mvn integration-test' however, artifacts will
@@ -256,7 +256,6 @@
 
     ////////////////////////////////////////////////////////////
     // A load of Pax Exam definitions for easier (typo-free) provisioning
-
     protected static MavenArtifactProvisionOption amdatuJaxRs() {
         return 
mavenBundle().groupId("org.amdatu.web.rest").artifactId("jaxrs").versionAsInProject();
     }
@@ -353,27 +352,38 @@
         return 
mavenBundle().groupId("org.amdatu.web").artifactId("jsp").versionAsInProject();
     }
 
-    protected static WrappedUrlProvisionOption commonsHttpClient() {
-        return 
wrappedBundle(mavenBundle().groupId("commons-httpclient").artifactId("commons-httpclient"));
-    }
-
-    protected static WrappedUrlProvisionOption commonsLogging() {
-        return 
wrappedBundle(mavenBundle().groupId("commons-logging").artifactId("commons-logging"));
-    }
-
-    protected static WrappedUrlProvisionOption commonsCodec() {
-        return 
wrappedBundle(mavenBundle().groupId("commons-codec").artifactId("commons-codec"));
-    }
-    
     protected static MavenArtifactProvisionOption amdatuGadgetManagement() {
         return 
mavenBundle().groupId("org.amdatu.opensocial").artifactId("gadgetmanagement").versionAsInProject();
     }
-    
+
     protected static MavenArtifactProvisionOption amdatuLogin() {
         return 
mavenBundle().groupId("org.amdatu.authorization.login").artifactId("service").versionAsInProject();
     }
-    
+
     protected static MavenArtifactProvisionOption amdatuShindig() {
         return 
mavenBundle().groupId("org.amdatu.opensocial").artifactId("shindig").versionAsInProject();
     }
+
+    // Jar files wrapper in a bundle
+       protected static WrappedUrlProvisionOption commonsHttpClient() {
+               return 
wrappedBundle(mavenBundle().groupId("commons-httpclient").artifactId("commons-httpclient"));
+       }
+
+       protected static WrappedUrlProvisionOption commonsLogging() {
+               return 
wrappedBundle(mavenBundle().groupId("commons-logging").artifactId("commons-logging"));
+       }
+
+       protected static WrappedUrlProvisionOption commonsCodec() {
+               return 
wrappedBundle(mavenBundle().groupId("commons-codec").artifactId("commons-codec"));
+       }
+
+       protected static WrappedUrlProvisionOption javaxServlet() {
+               // We need to create a bundle holding the 2.3 servlet API 
(required by SLF4J used by Cassandra) if the http service
+               // is not deployed. Since the org.osgi.compendium_4 and other 
bundles include javax.servlet with explicit version
+               // 2.1.0, we must explicitly set the version.
+               String version = "2.3";
+               String javaxServlet = "javax.servlet;version=\"" + version + 
"\"";
+               String javaxServletHttp = 
"javax.servlet.http;uses:=\"javax.servlet\";version=\"" + version + "\"";
+               return 
wrappedBundle(mavenBundle().groupId("servletapi").artifactId("servletapi")).exports(javaxServlet,
 javaxServletHttp);
+       }
 }

Modified: 
trunk/integration-tests/src/test/java/org/amdatu/test/integration/tests/CassandraDaemonIntegrationTest.java
==============================================================================
--- 
trunk/integration-tests/src/test/java/org/amdatu/test/integration/tests/CassandraDaemonIntegrationTest.java
 (original)
+++ 
trunk/integration-tests/src/test/java/org/amdatu/test/integration/tests/CassandraDaemonIntegrationTest.java
 Fri Nov 19 15:12:36 2010
@@ -32,7 +32,6 @@
 import org.apache.felix.dm.Component;
 import org.apache.felix.dm.DependencyManager;
 import org.junit.After;
-import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.ops4j.pax.exam.Option;
@@ -59,6 +58,7 @@
     protected Option provisionBundles() {
         // Deploy bundles needed by cassandra daemon integration test
         return provision(
+               javaxServlet(), // Required if the httpservice is not deployed
             amdatuCassandraApplication(),
             amdatuCassandraListener(),
             amdatuCassandraPersistenceManager());

Modified: 
trunk/integration-tests/src/test/java/org/amdatu/test/integration/tests/CassandraPersistenceManagerTest.java
==============================================================================
--- 
trunk/integration-tests/src/test/java/org/amdatu/test/integration/tests/CassandraPersistenceManagerTest.java
        (original)
+++ 
trunk/integration-tests/src/test/java/org/amdatu/test/integration/tests/CassandraPersistenceManagerTest.java
        Fri Nov 19 15:12:36 2010
@@ -65,6 +65,7 @@
     protected Option provisionBundles() {
         // Deploy bundles needed by cassandra daemon integration test
         return provision(
+               javaxServlet(), // Required if the httpservice is not deployed
             amdatuCassandraApplication(),
             amdatuCassandraListener(),
             amdatuCassandraPersistenceManager());

Modified: 
trunk/integration-tests/src/test/java/org/amdatu/test/integration/tests/GadgetManagementServiceTest.java
==============================================================================
--- 
trunk/integration-tests/src/test/java/org/amdatu/test/integration/tests/GadgetManagementServiceTest.java
    (original)
+++ 
trunk/integration-tests/src/test/java/org/amdatu/test/integration/tests/GadgetManagementServiceTest.java
    Fri Nov 19 15:12:36 2010
@@ -63,6 +63,8 @@
             amdatuCassandraListener(),
             amdatuCassandraPersistenceManager(),
             felixHttpServiceJetty(),
+            slingCommons(),
+            slingMime(),
             paxUserAdmin(),
             amdatuUserAdminCassandraStore(),
             amdatuHttpContext(),

Modified: 
trunk/integration-tests/src/test/java/org/amdatu/test/integration/tests/HttpServiceTest.java
==============================================================================
--- 
trunk/integration-tests/src/test/java/org/amdatu/test/integration/tests/HttpServiceTest.java
        (original)
+++ 
trunk/integration-tests/src/test/java/org/amdatu/test/integration/tests/HttpServiceTest.java
        Fri Nov 19 15:12:36 2010
@@ -16,7 +16,8 @@
  */
 package org.amdatu.test.integration.tests;
 
-import static junit.framework.Assert.*;
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertTrue;
 import static org.ops4j.pax.exam.CoreOptions.provision;
 
 import java.io.IOException;
@@ -34,8 +35,6 @@
 import javax.servlet.ServletResponse;
 import javax.servlet.http.HttpServletResponse;
 
-import junit.framework.Assert;
-
 import org.amdatu.test.integration.base.IntegrationTestBase;
 import org.amdatu.web.httpcontext.HttpContextServiceFactory;
 import org.amdatu.web.httpcontext.ResourceProvider;
@@ -47,7 +46,6 @@
 import org.apache.felix.dm.Component;
 import org.apache.felix.dm.DependencyManager;
 import org.junit.After;
-import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.ops4j.pax.exam.Option;
@@ -86,6 +84,8 @@
         return provision(
             felixHttpServiceJetty(),
             felixHttpServiceWhiteboard(),
+            slingCommons(),
+            slingMime(),            
             commonsHttpClient(),
             paxSwissbox(),
             ops4jBaseLang(),
@@ -95,16 +95,6 @@
             amdatuJspSupport());
     }
 
-    @Before
-    public void setUp() throws Exception {
-        // Note 
-        setupTest();
-        m_baseUrl = "http://localhost:"; + getHttpPortNr();
-
-        // Initialize the HTTP Context in which the filter, servlet and JSP 
under test are registered
-        m_httpContextComponent = 
m_httpContextFactoryService.create(m_bundleContext, m_testServlet);
-    }
-
     @Override
     protected Component[] getDependencies(DependencyManager manager) {
         // We register a servlet filter (whiteboard-style) that adds a test 
header to each HTTP response
@@ -114,7 +104,7 @@
         filterProperties.put("service.ranking", "0");
         Component filterComponent = manager.createComponent()
                 .setImplementation(new TestFilter())
-                .setInterface(new String[] { Filter.class.getName(), 
TestFilterInterface.class.getName() },
+                .setInterface(new String[] {Filter.class.getName(), 
TestFilterInterface.class.getName()},
                         filterProperties);
 
         // Now we register a test servlet, also whiteboard-style
@@ -125,8 +115,7 @@
         Component servletComponent = manager.createComponent()
                 .setImplementation(m_testServlet)
                 .setInterface(
-                        new String[] { Servlet.class.getName(), 
TestServletInterface.class.getName(),
-                                ResourceProvider.class.getName() },
+                        new String[] { Servlet.class.getName(), 
TestServletInterface.class.getName(), ResourceProvider.class.getName() },
                         servletProperties);
 
         Component testComponent = manager.createComponent()
@@ -144,9 +133,18 @@
     public void tearDown() throws Exception {
         m_httpContextComponent.stop();
     }
+    
+    private void initialize() throws Exception {
+       m_baseUrl = "http://localhost:"; + getHttpPortNr();
+       
+       // Initialize the HTTP Context in which the filter, servlet and JSP 
under test are registered
+        m_httpContextComponent = 
m_httpContextFactoryService.create(m_bundleContext, m_testServlet);
+    }
 
     @Test
     public void testFilter() throws Exception {
+       initialize();
+        
         // Our filter should be registered, use httpclient to do a GET 
request. The filter should
         // set some response header and we check if this header has been set
         HttpClient httpClient = new HttpClient();
@@ -184,6 +182,8 @@
 
     @Test
     public void testJsp() throws Exception {
+       initialize();
+       
         // Our filter should be registered, use httpclient to do a GET 
request. The filter should
         // set some response header and we check if this header has been set
         HttpClient httpClient = new HttpClient();

Modified: 
trunk/integration-tests/src/test/java/org/amdatu/test/integration/tests/TenantManagementServiceTest.java
==============================================================================
--- 
trunk/integration-tests/src/test/java/org/amdatu/test/integration/tests/TenantManagementServiceTest.java
    (original)
+++ 
trunk/integration-tests/src/test/java/org/amdatu/test/integration/tests/TenantManagementServiceTest.java
    Fri Nov 19 15:12:36 2010
@@ -63,6 +63,7 @@
 
     protected Option provisionBundles() {
         return provision(
+               javaxServlet(), // Required if the httpservice is not deployed
             amdatuCassandraApplication(),
             amdatuCassandraListener(),
             amdatuCassandraPersistenceManager(),

Modified: 
trunk/integration-tests/src/test/java/org/amdatu/test/integration/tests/UserAdminStoreTest.java
==============================================================================
--- 
trunk/integration-tests/src/test/java/org/amdatu/test/integration/tests/UserAdminStoreTest.java
     (original)
+++ 
trunk/integration-tests/src/test/java/org/amdatu/test/integration/tests/UserAdminStoreTest.java
     Fri Nov 19 15:12:36 2010
@@ -56,8 +56,11 @@
 
     protected Option provisionBundles() {
         return provision(
+               javaxServlet(), // Required if the httpservice is not deployed
             felixHttpServiceJetty(),
             felixHttpServiceWhiteboard(),
+            slingCommons(),
+            slingMime(),   
             amdatuHttpContext(),
             amdatuJaxRs(),
             amdatuCassandraApplication(),

Reply via email to