usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject [47/50] [abbrv] incubator-usergrid git commit: Fixes TokenServiceIT and bug in ManagementService counter test
Date Fri, 12 Dec 2014 14:30:46 GMT
Fixes TokenServiceIT and bug in ManagementService counter test


Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/31bb3f18
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/31bb3f18
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/31bb3f18

Branch: refs/heads/no-source-in-es
Commit: 31bb3f18d358faa30ab451cfaf97aa78823d65fe
Parents: 2175834
Author: Todd Nine <tnine@apigee.com>
Authored: Wed Dec 10 17:03:34 2014 -0700
Committer: Todd Nine <tnine@apigee.com>
Committed: Wed Dec 10 17:03:34 2014 -0700

----------------------------------------------------------------------
 .../cassandra/ManagementServiceIT.java          |  5 ++-
 .../security/tokens/TokenServiceIT.java         | 40 ++++++++------------
 .../usergrid/services/ServiceFactoryIT.java     |  4 +-
 3 files changed, 21 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/31bb3f18/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
b/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
index ddb2bbb..6957097 100644
--- a/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
@@ -161,9 +161,10 @@ public class ManagementServiceIT {
         Map<String, Long> counts = em.getApplicationCounters();
         LOG.info( JsonUtils.mapToJsonString( counts ) );
         LOG.info( JsonUtils.mapToJsonString( em.getCounterNames() ) );
-        assertNotNull( counts.get( "admin_logins" ) );
 
-        final long startCount = counts.get( "admin_logins" );
+        final Long existingCounts = counts.get( "admin_logins" );
+
+        final long startCount = existingCounts == null ? 0 : existingCounts;
 
 
         setup.getMgmtSvc().countAdminUserAction( adminUser, "login" );

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/31bb3f18/stack/services/src/test/java/org/apache/usergrid/security/tokens/TokenServiceIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/security/tokens/TokenServiceIT.java
b/stack/services/src/test/java/org/apache/usergrid/security/tokens/TokenServiceIT.java
index 49d939c..67bc035 100644
--- a/stack/services/src/test/java/org/apache/usergrid/security/tokens/TokenServiceIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/security/tokens/TokenServiceIT.java
@@ -20,6 +20,7 @@ package org.apache.usergrid.security.tokens;
 import java.util.HashMap;
 import java.util.Map;
 
+import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.ClassRule;
 import org.junit.Rule;
@@ -27,6 +28,7 @@ import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import org.apache.usergrid.NewOrgAppAdminRule;
 import org.apache.usergrid.ServiceITSetup;
 import org.apache.usergrid.ServiceITSetupImpl;
 import org.apache.usergrid.cassandra.CassandraResource;
@@ -73,15 +75,13 @@ public class TokenServiceIT {
     public static ServiceITSetup setup = new ServiceITSetupImpl( cassandraResource, elasticSearchResource
);
 
 
-    @BeforeClass
-    public static void setup() throws Exception {
-        log.info( "in setup" );
-        adminUser =
-                setup.getMgmtSvc().createAdminUser( "edanuff34", "Ed Anuff", "ed@anuff34.com",
"test", false, false );
-        OrganizationInfo organization = setup.getMgmtSvc().createOrganization( "TokenServiceTestOrg",
adminUser, true );
+    @Rule
+    public NewOrgAppAdminRule newOrgAppAdminRule = new NewOrgAppAdminRule( setup );
 
-        // TODO update to organizationName/applicationName
-        setup.getMgmtSvc().createApplication( organization.getUuid(), "TokenServiceTestOrg/ed-application"
).getId();
+    @Before
+    public void setup() throws Exception {
+        log.info( "in setup" );
+        adminUser = newOrgAppAdminRule.getAdminInfo();
     }
 
 
@@ -91,8 +91,8 @@ public class TokenServiceIT {
 
         Map<String, Object> data = new HashMap<String, Object>() {
             {
-                put( "email", "ed@anuff34.com" );
-                put( "username", "edanuff34" );
+                put( "email", adminUser.getEmail());
+                put( "username", adminUser.getUsername());
             }
         };
 
@@ -106,8 +106,8 @@ public class TokenServiceIT {
         long last_access = tokenInfo.getAccessed();
 
         assertEquals( "email_confirm", tokenInfo.getType() );
-        assertEquals( "ed@anuff34.com", tokenInfo.getState().get( "email" ) );
-        assertEquals( "edanuff34", tokenInfo.getState().get( "username" ) );
+        assertEquals( adminUser.getEmail(), tokenInfo.getState().get( "email" ) );
+        assertEquals( adminUser.getUsername(), tokenInfo.getState().get( "username" ) );
 
         tokenInfo = setup.getTokenSvc().getTokenInfo( tokenStr );
 
@@ -311,9 +311,7 @@ public class TokenServiceIT {
     @Test
     public void appDefaultExpiration() throws Exception {
 
-        OrganizationOwnerInfo orgInfo =
-                setup.getMgmtSvc().createOwnerAndOrganization( "foo", "foobar", "foobar",
"foo@bar.com", "foobar" );
-        ApplicationInfo appInfo = setup.getMgmtSvc().createApplication( orgInfo.getOrganization().getUuid(),
"bar" );
+        ApplicationInfo appInfo = newOrgAppAdminRule.getApplicationInfo();
         EntityManager em = setup.getEmf().getEntityManager( appInfo.getId() );
         Application app = em.getApplication();
         AuthPrincipalInfo userPrincipal =
@@ -328,11 +326,7 @@ public class TokenServiceIT {
 
     @Test
     public void appExpiration() throws Exception {
-
-        OrganizationOwnerInfo orgInfo =
-                setup.getMgmtSvc().createOwnerAndOrganization( "foo2", "foobar2", "foobar",
"foo2@bar.com", "foobar" );
-
-        ApplicationInfo appInfo = setup.getMgmtSvc().createApplication( orgInfo.getOrganization().getUuid(),
"bar" );
+        ApplicationInfo appInfo = newOrgAppAdminRule.getApplicationInfo();
 
         EntityManager em = setup.getEmf().getEntityManager( appInfo.getId() );
 
@@ -409,11 +403,7 @@ public class TokenServiceIT {
 
     @Test
     public void appExpirationInfinite() throws Exception {
-
-        OrganizationOwnerInfo orgInfo = setup.getMgmtSvc().createOwnerAndOrganization( "appExpirationInfinite",
-                "appExpirationInfinite", "foobar", "appExpirationInfinite@bar.com", "foobar"
);
-
-        ApplicationInfo appInfo = setup.getMgmtSvc().createApplication( orgInfo.getOrganization().getUuid(),
"bar" );
+        ApplicationInfo appInfo = newOrgAppAdminRule.getApplicationInfo();
 
         EntityManager em = setup.getEmf().getEntityManager( appInfo.getId() );
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/31bb3f18/stack/services/src/test/java/org/apache/usergrid/services/ServiceFactoryIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/services/ServiceFactoryIT.java
b/stack/services/src/test/java/org/apache/usergrid/services/ServiceFactoryIT.java
index 71152c9..e4e576f 100644
--- a/stack/services/src/test/java/org/apache/usergrid/services/ServiceFactoryIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/services/ServiceFactoryIT.java
@@ -26,6 +26,8 @@ import org.apache.usergrid.cassandra.Concurrent;
 
 import org.apache.usergrid.services.simple.SimpleService;
 
+import static org.apache.usergrid.TestHelper.uniqueApp;
+import static org.apache.usergrid.TestHelper.uniqueOrg;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 
@@ -40,7 +42,7 @@ public class ServiceFactoryIT extends AbstractServiceIT {
     public void testPackagePrefixes() throws Exception {
         logger.info( "test package prefixes" );
 
-        UUID applicationId = setup.getEmf().createApplication( "org", "app" );
+        UUID applicationId = setup.getEmf().createApplication(uniqueOrg(), uniqueApp() );
         ServiceManager sm = setup.getSmf().getServiceManager( applicationId );
         Service service = sm.getService( "simple" );
         assertEquals( "/simple", service.getServiceType() );


Mime
View raw message