Author: ivol
Date: Mon Oct 18 09:54:04 2010
New Revision: 176

Log:
[AMDATU-107] Attached integration tests to the integration-test lifecycle phase

Added:
   trunk/unit-tests/src/test/java/org/amdatu/test/integration/
   trunk/unit-tests/src/test/java/org/amdatu/test/integration/tenant/
      - copied from r175, 
/trunk/unit-tests/src/test/java/org/amdatu/test/tenant/
Removed:
   trunk/unit-tests/src/test/java/org/amdatu/test/tenant/
Modified:
   trunk/unit-tests/pom.xml
   
trunk/unit-tests/src/test/java/org/amdatu/test/integration/tenant/TenantManagementServiceTest.java
   
trunk/unit-tests/src/test/java/org/amdatu/test/integration/tenant/mock/TenantDAOMock.java

Modified: trunk/unit-tests/pom.xml
==============================================================================
--- trunk/unit-tests/pom.xml    (original)
+++ trunk/unit-tests/pom.xml    Mon Oct 18 09:54:04 2010
@@ -110,6 +110,7 @@
         <artifactId>depends-maven-plugin</artifactId>
         <executions>
           <execution>
+            <phase>integration-test</phase>
             <id>generate-depends-file</id>
             <goals>
               <goal>generate-depends-file</goal>
@@ -123,6 +124,7 @@
         <artifactId>maven-paxexam-plugin</artifactId>
         <executions>
           <execution>
+            <phase>integration-test</phase>
             <id>generate-config</id>
             <goals>
               <goal>generate-config</goal>
@@ -134,7 +136,29 @@
             <platform>${target-framework}</platform>
           </options>
         </configuration>
-      </plugin>      
+      </plugin>
+      
+      <!-- Enable the surefire plugin only in the integration-test
+           phase such that we can use Pax Exam for integration testing -->
+      <plugin>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>run-integration-test</id>
+            <phase>integration-test</phase>
+            <goals>
+              <goal>test</goal>
+            </goals>
+            <configuration>
+               <skip>false</skip>
+            </configuration>
+          </execution>
+        </executions>
+        <configuration>
+          <skip>true</skip>
+        </configuration>
+      </plugin>
+
     </plugins>
   </build> 
 </project>

Modified: 
trunk/unit-tests/src/test/java/org/amdatu/test/integration/tenant/TenantManagementServiceTest.java
==============================================================================
--- 
/trunk/unit-tests/src/test/java/org/amdatu/test/tenant/TenantManagementServiceTest.java
     (original)
+++ 
trunk/unit-tests/src/test/java/org/amdatu/test/integration/tenant/TenantManagementServiceTest.java
  Mon Oct 18 09:54:04 2010
@@ -14,8 +14,9 @@
  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
-package org.amdatu.test.tenant;
+package org.amdatu.test.integration.tenant;
 
+import static org.ops4j.pax.exam.CoreOptions.bundle;
 import static org.ops4j.pax.exam.CoreOptions.felix;
 import static org.ops4j.pax.exam.CoreOptions.frameworks;
 import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
@@ -34,7 +35,7 @@
 import org.amdatu.platform.tenant.TenantDAO;
 import org.amdatu.platform.tenant.TenantException;
 import org.amdatu.platform.tenant.TenantManagementService;
-import org.amdatu.test.tenant.mock.TenantDAOMock;
+import org.amdatu.test.integration.tenant.mock.TenantDAOMock;
 import org.apache.felix.dm.DependencyManager;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -44,13 +45,13 @@
 import org.ops4j.pax.exam.junit.JUnit4TestRunner;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
+import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.framework.ServiceReference;
 
 /**
  * This class provides a Unit test for testing the Tenant Management Service.
  * @author ivol
  */
-// TODO: using this test framework must be generalized, move dependencies to 
root pom
 // TODO: service ranking mechanism to enforce that mock dao is used must be 
tested after solving other issues
 // TODO: TenantImpl and TenantDAO has to be moved temporarily to the exported 
package in order for this test to use them
 @RunWith(JUnit4TestRunner.class)
@@ -81,6 +82,10 @@
                 
mavenBundle().groupId("org.apache.sling").artifactId("org.apache.sling.commons.osgi").versionAsInProject(),
 
                 // 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 
+                // not be deployed and so this will only work when artifacts 
have been deployed to the maven repository
+                // before, possibly using outdated artifacts.
                 
mavenBundle().groupId("org.amdatu.platform").artifactId("filebased-configuration").versionAsInProject(),
                 
mavenBundle().groupId("org.amdatu.platform").artifactId("httpcontext").versionAsInProject(),
                 
mavenBundle().groupId("org.amdatu.platform").artifactId("config-template-manager").versionAsInProject(),
@@ -88,7 +93,10 @@
                 
mavenBundle().groupId("org.amdatu.platform").artifactId("shindig-application").versionAsInProject(),
                 
mavenBundle().groupId("org.amdatu.platform").artifactId("cassandra-listener").versionAsInProject(),
                 
mavenBundle().groupId("org.amdatu.platform").artifactId("cassandra-persistencemanager").versionAsInProject(),
-                
mavenBundle().groupId("org.amdatu.platform").artifactId("tenant-service").versionAsInProject()));
+                
mavenBundle().groupId("org.amdatu.platform").artifactId("tenant-service").versionAsInProject(),
+                
+                // And finally deploy ourselves
+                
bundle("file:target/org.amdatu.platform.unit-tests-0.0.5-SNAPSHOT.jar")));
     }
 
     @Test
@@ -104,6 +112,15 @@
             TenantDAO.class.getName(), ht));
         System.out.println(">  TESTING:  TenantDAOMock service registered");
 
+        try {
+            ServiceReference[] tenantDAOs = 
m_bundleContext.getServiceReferences(TenantDAO.class.getName(), null);
+            for (ServiceReference ref : tenantDAOs) {
+                System.out.println(">  TESTING:  Tenant DAO = " 
+m_bundleContext.getService(ref));
+            }
+        } catch (InvalidSyntaxException e) {
+
+        }
+
         ServiceReference tenantMgrSR = 
m_bundleContext.getServiceReference(TenantManagementService.class.getName());
         TenantManagementService tenantManagementService =
             (TenantManagementService) m_bundleContext.getService(tenantMgrSR);

Modified: 
trunk/unit-tests/src/test/java/org/amdatu/test/integration/tenant/mock/TenantDAOMock.java
==============================================================================
--- 
/trunk/unit-tests/src/test/java/org/amdatu/test/tenant/mock/TenantDAOMock.java  
    (original)
+++ 
trunk/unit-tests/src/test/java/org/amdatu/test/integration/tenant/mock/TenantDAOMock.java
   Mon Oct 18 09:54:04 2010
@@ -14,7 +14,7 @@
  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
-package org.amdatu.test.tenant.mock;
+package org.amdatu.test.integration.tenant.mock;
 
 import java.util.ArrayList;
 import java.util.HashMap;

Reply via email to