Author: [email protected]
Date: Fri May 13 16:21:46 2011
New Revision: 1139

Log:
[AMDATUAUTH-23] Moved UserAdminRESTTest to Amdatu Auth

Removed:
   
trunk/amdatu-auth/test-integration/tests/src/test/java/org/amdatu/auth/test/integration/tests/util/OAuthTestBase.java
   
trunk/integration-tests/test-platform/src/test/java/org/amdatu/test/integration/tests/UserAdminRESTTest.java
Modified:
   
trunk/amdatu-auth/test-integration/base/src/main/java/org/amdatu/auth/test/integration/base/AuthFixture.java
   trunk/amdatu-auth/test-integration/tests/pom.xml
   
trunk/amdatu-auth/test-integration/tests/src/test/java/org/amdatu/auth/test/integration/tests/AuthTest.java
   
trunk/amdatu-auth/test-integration/tests/src/test/java/org/amdatu/auth/test/integration/tests/OAuthServiceConsumerRegistryTest.java
   
trunk/amdatu-auth/test-integration/tests/src/test/java/org/amdatu/auth/test/integration/tests/OAuthSignedRequestsTest.java
   
trunk/amdatu-auth/test-integration/tests/src/test/java/org/amdatu/auth/test/integration/tests/OAuthThreeLeggedTest.java
   
trunk/amdatu-auth/test-integration/tests/src/test/java/org/amdatu/auth/test/integration/tests/OAuthTwoLeggedTest.java

Modified: 
trunk/amdatu-auth/test-integration/base/src/main/java/org/amdatu/auth/test/integration/base/AuthFixture.java
==============================================================================
--- 
trunk/amdatu-auth/test-integration/base/src/main/java/org/amdatu/auth/test/integration/base/AuthFixture.java
        (original)
+++ 
trunk/amdatu-auth/test-integration/base/src/main/java/org/amdatu/auth/test/integration/base/AuthFixture.java
        Fri May 13 16:21:46 2011
@@ -26,6 +26,7 @@
 
 public class AuthFixture {
     public static final String HOSTNAME = "localhost";
+    public final static String IP = "127.0.0.1";
     public static final String PORTNR = "8080";
     
     public Option provision() {
@@ -48,7 +49,8 @@
             
mavenBundle().groupId("org.amdatu.auth").artifactId("org.amdatu.auth.oauth.client").versionAsInProject(),
             
mavenBundle().groupId("org.amdatu.auth").artifactId("org.amdatu.auth.oauth.server").versionAsInProject(),
             
mavenBundle().groupId("org.amdatu.auth").artifactId("org.amdatu.auth.oauth.consumerregistry-fs").versionAsInProject(),
-            
mavenBundle().groupId("org.amdatu.auth").artifactId("org.amdatu.auth.login.service").versionAsInProject()
+            
mavenBundle().groupId("org.amdatu.auth").artifactId("org.amdatu.auth.login.service").versionAsInProject(),
+            
mavenBundle().groupId("org.amdatu.auth").artifactId("org.amdatu.auth.useradmin.rest").versionAsInProject()
             );
     }
     

Modified: trunk/amdatu-auth/test-integration/tests/pom.xml
==============================================================================
--- trunk/amdatu-auth/test-integration/tests/pom.xml    (original)
+++ trunk/amdatu-auth/test-integration/tests/pom.xml    Fri May 13 16:21:46 2011
@@ -134,12 +134,19 @@
         <type>bundle</type>
       </dependency>
       <dependency>
-        <groupId>org.apache.auth</groupId>
+        <groupId>org.amdatu.auth</groupId>
         <artifactId>org.amdatu.auth.tokenstore.mem</artifactId>
         <version>${project.version}</version>
         <scope>compile</scope>
         <type>bundle</type>
       </dependency>
+      <dependency>
+        <groupId>org.amdatu.auth</groupId>
+        <artifactId>org.amdatu.auth.useradmin.rest</artifactId>
+        <version>${project.version}</version>
+        <scope>compile</scope>
+        <type>bundle</type>
+      </dependency>
     </dependencies>
   </dependencyManagement>
 
@@ -213,6 +220,11 @@
       <artifactId>org.amdatu.auth.tokenstore.mem</artifactId>
       <type>bundle</type>
     </dependency>
+    <dependency>
+      <groupId>org.amdatu.auth</groupId>
+      <artifactId>org.amdatu.auth.useradmin.rest</artifactId>
+      <type>bundle</type>
+    </dependency>
   </dependencies>
 
   <build>

Modified: 
trunk/amdatu-auth/test-integration/tests/src/test/java/org/amdatu/auth/test/integration/tests/AuthTest.java
==============================================================================
--- 
trunk/amdatu-auth/test-integration/tests/src/test/java/org/amdatu/auth/test/integration/tests/AuthTest.java
 (original)
+++ 
trunk/amdatu-auth/test-integration/tests/src/test/java/org/amdatu/auth/test/integration/tests/AuthTest.java
 Fri May 13 16:21:46 2011
@@ -29,9 +29,9 @@
 import javax.servlet.Servlet;
 
 import org.amdatu.auth.test.integration.base.AuthFixture;
+import org.amdatu.auth.test.integration.tests.util.AuthTestBase;
 import org.amdatu.auth.test.integration.tests.util.AuthUtils;
 import org.amdatu.auth.test.integration.tests.util.OAuthProtectedTestServlet;
-import org.amdatu.auth.test.integration.tests.util.OAuthTestBase;
 import org.amdatu.authentication.oauth.api.OAuthServiceConsumerRegistry;
 import org.amdatu.authentication.oauth.api.OAuthServiceProvider;
 import org.amdatu.authentication.oauth.server.OAuthAccessTokenServlet;
@@ -53,6 +53,7 @@
 import org.ops4j.pax.exam.junit.JUnit4TestRunner;
 import org.ops4j.pax.exam.spi.reactors.AllConfinedStagedReactorFactory;
 import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceReference;
 import org.osgi.service.http.HttpService;
 import org.osgi.service.log.LogService;
@@ -64,6 +65,9 @@
     public final static String TEST_USERNAME = "georged";
     public final static String TEST_PASSWORD = "georged";
     
+    public final static String ADMIN_USERNAME = "Administrator";
+    public final static String ADMIN_PASSWORD = "Administrator";
+    
     // Fixtures used by the Auth integration tests
     private CoreFixture m_coreFixture = new CoreFixture();
     private WebFixture m_webFixture = new WebFixture();
@@ -114,7 +118,7 @@
         BundleContext bundleContext = testContext.getBundleContext();
         ServiceReference[] servRef = 
bundleContext.getAllServiceReferences(clazz.getName(), null);
         if (servRef != null && servRef.length > 0) {
-            return (T) bundleContext.getService(servRef[0]);
+            return (T) 
bundleContext.getService(getServiceRefWithHighestRank(servRef));
         }
         
         T service = testContext.getService(clazz);
@@ -124,11 +128,35 @@
        
         servRef = bundleContext.getAllServiceReferences(clazz.getName(), null);
         if (servRef != null && servRef.length > 0) {
-            return (T) bundleContext.getService(servRef[0]);
+            return (T) 
bundleContext.getService(getServiceRefWithHighestRank(servRef));
         }
         return null;
     }
     
+    private ServiceReference getServiceRefWithHighestRank(ServiceReference[] 
servRefs) {
+        int maxRank = -1;
+        if (servRefs.length == 1) {
+            return servRefs[0];
+        }
+        ServiceReference maxServRef = null;
+        for (ServiceReference servRef : servRefs) {
+            Object prop = servRef.getProperty(Constants.SERVICE_RANKING);
+            int rank;
+            if (prop == null) {
+                rank = 0;
+            } else if (prop instanceof Integer) {
+                rank = (Integer) 
servRef.getProperty(Constants.SERVICE_RANKING);
+            } else {
+                rank = 
Integer.parseInt(servRef.getProperty(Constants.SERVICE_RANKING).toString());
+            }
+            if (rank >= maxRank) {
+                maxServRef = servRef;
+                maxRank = rank;
+            }
+        }
+        return maxServRef;
+    }
+    
     private <T> T assertAvailable(TestContext testContext, Class<T> 
serviceClass) throws Exception {
         T service = getService(testContext, serviceClass);
         assertThat("Expected a " + serviceClass.getName(), service, 
is(notNullValue()));
@@ -165,6 +193,7 @@
         test(OAuthSignedRequestsTest.class);
         test(OAuthThreeLeggedTest.class);
         test(OAuthTwoLeggedTest.class);
+        test(UserAdminRESTTest.class);
         
         // And we are done
         testContext.tearDown();
@@ -184,13 +213,13 @@
         m_dependencyManager.add(servletComponent);
     }
     
-    private <T extends OAuthTestBase> void test(Class<T> testClass) throws 
Exception {
+    private <T extends AuthTestBase> void test(Class<T> testClass) throws 
Exception {
         T test = testClass.newInstance();
         init(test);
         test.execute();
     }
     
-    private void init(OAuthTestBase test) {
+    private void init(AuthTestBase test) {
         test.setLogService(m_logService);
         test.setUserAdmin(m_userAdmin);
         test.setOAuthServiceProvider(m_oAuthServiceProvider);

Modified: 
trunk/amdatu-auth/test-integration/tests/src/test/java/org/amdatu/auth/test/integration/tests/OAuthServiceConsumerRegistryTest.java
==============================================================================
--- 
trunk/amdatu-auth/test-integration/tests/src/test/java/org/amdatu/auth/test/integration/tests/OAuthServiceConsumerRegistryTest.java
 (original)
+++ 
trunk/amdatu-auth/test-integration/tests/src/test/java/org/amdatu/auth/test/integration/tests/OAuthServiceConsumerRegistryTest.java
 Fri May 13 16:21:46 2011
@@ -18,7 +18,7 @@
 import java.io.IOException;
 
 import org.amdatu.auth.test.integration.base.AuthFixture;
-import org.amdatu.auth.test.integration.tests.util.OAuthTestBase;
+import org.amdatu.auth.test.integration.tests.util.AuthTestBase;
 import org.amdatu.auth.test.integration.tests.util.OAuthTestConsumer;
 import org.amdatu.auth.test.integration.tests.util.AuthUtils;
 import org.apache.commons.httpclient.HttpClient;
@@ -33,7 +33,7 @@
 import org.junit.Assert;
 import org.osgi.service.log.LogService;
 
-public class OAuthServiceConsumerRegistryTest extends OAuthTestBase {
+public class OAuthServiceConsumerRegistryTest extends AuthTestBase {
     private final static String CONSUMERS_REST_RESOURCE = 
"/rest/oauth/consumers";
 
     private String m_baseUrl;

Modified: 
trunk/amdatu-auth/test-integration/tests/src/test/java/org/amdatu/auth/test/integration/tests/OAuthSignedRequestsTest.java
==============================================================================
--- 
trunk/amdatu-auth/test-integration/tests/src/test/java/org/amdatu/auth/test/integration/tests/OAuthSignedRequestsTest.java
  (original)
+++ 
trunk/amdatu-auth/test-integration/tests/src/test/java/org/amdatu/auth/test/integration/tests/OAuthSignedRequestsTest.java
  Fri May 13 16:21:46 2011
@@ -27,7 +27,7 @@
 import net.oauth.OAuthMessage;
 
 import org.amdatu.auth.test.integration.base.AuthFixture;
-import org.amdatu.auth.test.integration.tests.util.OAuthTestBase;
+import org.amdatu.auth.test.integration.tests.util.AuthTestBase;
 import org.amdatu.auth.test.integration.tests.util.OAuthTestConsumer;
 import org.amdatu.authentication.oauth.api.ConsumerNotFoundException;
 import org.amdatu.authentication.oauth.api.ConsumerRegistryStorageException;
@@ -40,7 +40,7 @@
  * 
  * @author ivol
  */
-public class OAuthSignedRequestsTest extends OAuthTestBase {
+public class OAuthSignedRequestsTest extends AuthTestBase {
     
     public void execute() throws Exception {
         // Step 1: Register a service consumer

Modified: 
trunk/amdatu-auth/test-integration/tests/src/test/java/org/amdatu/auth/test/integration/tests/OAuthThreeLeggedTest.java
==============================================================================
--- 
trunk/amdatu-auth/test-integration/tests/src/test/java/org/amdatu/auth/test/integration/tests/OAuthThreeLeggedTest.java
     (original)
+++ 
trunk/amdatu-auth/test-integration/tests/src/test/java/org/amdatu/auth/test/integration/tests/OAuthThreeLeggedTest.java
     Fri May 13 16:21:46 2011
@@ -24,7 +24,7 @@
 import org.amdatu.auth.test.integration.base.AuthFixture;
 import org.amdatu.auth.test.integration.tests.util.AuthUtils;
 import org.amdatu.auth.test.integration.tests.util.OAuthProtectedTestServlet;
-import org.amdatu.auth.test.integration.tests.util.OAuthTestBase;
+import org.amdatu.auth.test.integration.tests.util.AuthTestBase;
 import org.amdatu.auth.test.integration.tests.util.OAuthTestConsumer;
 import org.amdatu.authentication.oauth.api.ConsumerNotFoundException;
 import org.amdatu.authentication.oauth.api.ConsumerRegistryStorageException;
@@ -38,7 +38,7 @@
  *
  * @author ivol
  */
-public class OAuthThreeLeggedTest extends OAuthTestBase {
+public class OAuthThreeLeggedTest extends AuthTestBase {
 
     public void execute() throws Exception {
         // Step 1: Register a service consumer

Modified: 
trunk/amdatu-auth/test-integration/tests/src/test/java/org/amdatu/auth/test/integration/tests/OAuthTwoLeggedTest.java
==============================================================================
--- 
trunk/amdatu-auth/test-integration/tests/src/test/java/org/amdatu/auth/test/integration/tests/OAuthTwoLeggedTest.java
       (original)
+++ 
trunk/amdatu-auth/test-integration/tests/src/test/java/org/amdatu/auth/test/integration/tests/OAuthTwoLeggedTest.java
       Fri May 13 16:21:46 2011
@@ -25,14 +25,14 @@
 
 import org.amdatu.auth.test.integration.base.AuthFixture;
 import org.amdatu.auth.test.integration.tests.util.AuthUtils;
-import org.amdatu.auth.test.integration.tests.util.OAuthTestBase;
+import org.amdatu.auth.test.integration.tests.util.AuthTestBase;
 import org.amdatu.auth.test.integration.tests.util.OAuthTestConsumer;
 import org.amdatu.authentication.oauth.api.OAuthServiceConsumer;
 import org.amdatu.authentication.oauth.client.OAuthResourceOwnerClient;
 import org.amdatu.authentication.oauth.client.OAuthServiceConsumerClient;
 import org.osgi.service.log.LogService;
 
-public class OAuthTwoLeggedTest extends OAuthTestBase {
+public class OAuthTwoLeggedTest extends AuthTestBase {
 
     public void execute() throws Exception {
        // Since this test is not tenant aware, verify that there is only 1 
tenant
_______________________________________________
Amdatu-commits mailing list
[email protected]
http://lists.amdatu.org/mailman/listinfo/amdatu-commits

Reply via email to