usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sfeld...@apache.org
Subject incubator-usergrid git commit: finished test
Date Tue, 06 Jan 2015 16:29:34 GMT
Repository: incubator-usergrid
Updated Branches:
  refs/heads/USERGRID-313 e964551e7 -> 01173d9a0


finished 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/01173d9a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/01173d9a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/01173d9a

Branch: refs/heads/USERGRID-313
Commit: 01173d9a00b1d013edf1d3fb047ec4b5f1c2852f
Parents: e964551
Author: Shawn Feldman <sfeldman@apache.org>
Authored: Tue Jan 6 09:29:10 2015 -0700
Committer: Shawn Feldman <sfeldman@apache.org>
Committed: Tue Jan 6 09:29:10 2015 -0700

----------------------------------------------------------------------
 .../collection/users/OwnershipResourceIT.java   | 67 +++++++++++++++-----
 1 file changed, 50 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/01173d9a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/OwnershipResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/OwnershipResourceIT.java
b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/OwnershipResourceIT.java
index 3e4e94d..fc85ca0 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/OwnershipResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/OwnershipResourceIT.java
@@ -20,6 +20,7 @@ package org.apache.usergrid.rest.applications.collection.users;
 import com.fasterxml.jackson.databind.JsonNode;
 import java.io.IOException;
 
+import com.sun.jersey.api.client.UniformInterfaceException;
 import org.apache.usergrid.rest.test.resource2point0.AbstractRestIT;
 import org.apache.usergrid.rest.test.resource2point0.endpoints.CollectionEndpoint;
 import org.apache.usergrid.rest.test.resource2point0.model.*;
@@ -53,7 +54,7 @@ public class OwnershipResourceIT extends AbstractRestIT {
         String email = "testuser1@usergrid.org";
         String email2 = "testuser2@usergrid.org";
 
-        user2 = new User("testuser2","testuser2", email, "password" );
+        user2 = new User("testuser2","testuser2", email2, "password" );
 
         user1 = new User("testuser1","testuser1", email, "password" );
         user1 = new User(this.usersResource.post(user1));
@@ -127,8 +128,13 @@ public class OwnershipResourceIT extends AbstractRestIT {
         assertEquals("device1", data.get("name").toString());
 
         // check we can't see device2
-        data = devices.entity("device2").get();
-        assertNull( data );
+        int status = 0;
+        try {
+            data = devices.entity("device2").get();
+        }catch (UniformInterfaceException e){
+            status = e.getResponse().getStatus();
+        }
+        assertEquals( status,404 );
 
         // do a collection load, make sure we're not loading device 2
         Collection devicesData = devices.get();
@@ -146,8 +152,13 @@ public class OwnershipResourceIT extends AbstractRestIT {
         assertEquals( "device2", data.get("name").toString() );
 
         // check we can't see device1
+        status = 0;
+        try{
         data = devices.entity("device1").get();
-        assertNull( data );
+        }catch (UniformInterfaceException e){
+            status = e.getResponse().getStatus();
+        }
+        assertEquals( status,404 );
 
         // do a collection load, make sure we're not loading device 1
         devicesData = devices.get();
@@ -157,15 +168,14 @@ public class OwnershipResourceIT extends AbstractRestIT {
 
         // we should see both devices when loaded from the root application
 
+        devices  = this.app().collection("devices");
         // test for user 1
         token = this.app().token().post(new Token(user1.getUsername(),"password"));
 
-        devices = usersResource.entity(user1).collection("devices");
         data = devices.entity("device1").get();
 
         assertNotNull( data );
         assertEquals( "device1", data.get("name").toString() );
-
         data = devices.entity("device2").get();
 
         assertNotNull( data );
@@ -174,7 +184,8 @@ public class OwnershipResourceIT extends AbstractRestIT {
         // test for user 2
         token = this.app().token().post(new Token(user2.getUsername(),"password"));
 
-        data =usersResource.entity(user2).collection("devices").entity( "device1" ).get();
+
+        data = devices.entity( "device1" ).get();
 
         assertNotNull( data );
         assertEquals( "device1",data.get( "name" ).toString() );
@@ -242,17 +253,27 @@ public class OwnershipResourceIT extends AbstractRestIT {
         assertEquals( "4peaks", data.get("name").toString() );
 
         // check we can't see arrogantbutcher by name or id
-        data = likeRestaurants.entity( "arrogantbutcher" ).get();
-        assertNull( data );
+        int status = 200;
+        try {
+            data = likeRestaurants.entity("arrogantbutcher").get();
+        }catch (UniformInterfaceException e){
+            status = e.getResponse().getStatus();
+        }
+        assertEquals(status, 404);
 
-        data = likeRestaurants.entity( arrogantButcherId ).get();
-        assertNull( data );
+        status = 200;
+        try {
+            data = likeRestaurants.entity( arrogantButcherId ).get();
+        }catch (UniformInterfaceException e){
+            status = e.getResponse().getStatus();
+        }
+        assertEquals(status, 404);
 
         // do a collection load, make sure we're not entities we shouldn't see
         Collection collectionData = likeRestaurants.get();
 
         assertEquals("4peaks", collectionData.next().get("name").toString());
-        assertNull( collectionData.next() );
+        assertTrue( !collectionData.hasNext() );
 
         // log in as user 2 and check it
         this.app().token().post(new Token(user2.getUsername(),"password"));
@@ -269,17 +290,29 @@ public class OwnershipResourceIT extends AbstractRestIT {
         assertEquals( "arrogantbutcher", data.get("name").toString() );
 
         // check we can't see 4peaks
-        data = likeRestaurants.entity( "4peaks" ).get();
-        assertNull( data );
+         status = 200;
+        try {
+            data = likeRestaurants.entity( "4peaks" ).get();
+        }catch (UniformInterfaceException e){
+            status = e.getResponse().getStatus();
+        }
+        assertEquals( status,404 );
 
-        data = likeRestaurants.entity( peaksId ).get();
-        assertNull( data );
+
+
+        status = 200;
+        try {
+            data = likeRestaurants.entity( peaksId ).get();
+
+        }catch (UniformInterfaceException e){
+            status = e.getResponse().getStatus();
+        }
 
         // do a collection load, make sure we're not loading device 1
         collectionData = likeRestaurants.get();
 
         assertEquals("arrogantbutcher", collectionData.next().get("name").toString());
-        assertNull( collectionData.next() );
+        assertTrue( !collectionData.hasNext() );
 
         // we should see both devices when loaded from the root application
 


Mime
View raw message