You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by jo...@apache.org on 2015/07/25 19:00:51 UTC

[3/5] incubator-usergrid git commit: Added unit test

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

Branch: refs/heads/master
Commit: 28911122f38200e713ada987b3fddf5d118d0308
Parents: 59b15d2
Author: arun.ram <ar...@spartasystems.com>
Authored: Thu Jul 9 22:34:23 2015 -0400
Committer: arun.ram <ar...@spartasystems.com>
Committed: Thu Jul 9 22:34:23 2015 -0400

----------------------------------------------------------------------
 .../organizations/OrganizationResourceIT.java   | 24 ++++++++++++++++++++
 1 file changed, 24 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/28911122/stack/rest/src/test/java/org/apache/usergrid/rest/management/organizations/OrganizationResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/management/organizations/OrganizationResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/management/organizations/OrganizationResourceIT.java
index b41f2ec..c519353 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/management/organizations/OrganizationResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/management/organizations/OrganizationResourceIT.java
@@ -17,7 +17,10 @@
 package org.apache.usergrid.rest.management.organizations;
 
 
+import com.sun.jersey.api.client.UniformInterfaceException;
 import org.apache.usergrid.rest.management.organizations.OrganizationsResource;
+
+import java.net.URLEncoder;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -32,7 +35,9 @@ import org.apache.usergrid.rest.AbstractRestIT;
 import org.apache.usergrid.rest.TestContextSetup;
 
 import junit.framework.Assert;
+import org.usergrid.java.client.response.ApiResponse;
 
+import static junit.framework.Assert.fail;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.apache.usergrid.utils.MapUtils.hashMap;
@@ -84,4 +89,23 @@ public class OrganizationResourceIT extends AbstractRestIT {
                 node.get( "organization" ).get( OrganizationsResource.ORGANIZATION_PROPERTIES ).get( "securityLevel" )
                     .asInt() );
     }
+
+    @Test
+    /**
+     * Test that non-permitted characters in application name results in IllegalArgumentException
+     */
+    public void testInvalidApplicationName() throws Exception {
+        try {
+            final String encodedAppName = URLEncoder.encode("<bob>", "UTF-8");
+            resource().path("/applications/" + encodedAppName).get( String.class );
+            fail("Expected exception");
+        }
+        catch (UniformInterfaceException e) {
+            final ApiResponse response = e.getResponse().getEntity(ApiResponse.class);
+            assertEquals("Incorrect exception type",
+                    IllegalArgumentException.class.getName(), response.getException());
+            Assert.assertEquals("Incorrect error description",
+                    "Invalid application name", response.getErrorDescription());
+        }
+    }
 }