directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r1533912 - in /directory/escimo/trunk/tests/src/test/java/org/apache/directory/scim: JettyServer.java UserResourceTest.java
Date Sun, 20 Oct 2013 14:13:19 GMT
Author: kayyagari
Date: Sun Oct 20 14:13:19 2013
New Revision: 1533912

URL: http://svn.apache.org/r1533912
Log:
test for adding groups

Modified:
    directory/escimo/trunk/tests/src/test/java/org/apache/directory/scim/JettyServer.java
    directory/escimo/trunk/tests/src/test/java/org/apache/directory/scim/UserResourceTest.java

Modified: directory/escimo/trunk/tests/src/test/java/org/apache/directory/scim/JettyServer.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/tests/src/test/java/org/apache/directory/scim/JettyServer.java?rev=1533912&r1=1533911&r2=1533912&view=diff
==============================================================================
--- directory/escimo/trunk/tests/src/test/java/org/apache/directory/scim/JettyServer.java
(original)
+++ directory/escimo/trunk/tests/src/test/java/org/apache/directory/scim/JettyServer.java
Sun Oct 20 14:13:19 2013
@@ -186,6 +186,15 @@ public class JettyServer
         t.join();
     }
     
+    /**
+     * @return the adminSession
+     */
+    public static CoreSession getAdminSession()
+    {
+        return adminSession;
+    }
+
+
     private static void checkForJdk6Compliance( String classpath ) throws Exception
     {
         String[] files = classpath.split( ":" );

Modified: directory/escimo/trunk/tests/src/test/java/org/apache/directory/scim/UserResourceTest.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/tests/src/test/java/org/apache/directory/scim/UserResourceTest.java?rev=1533912&r1=1533911&r2=1533912&view=diff
==============================================================================
--- directory/escimo/trunk/tests/src/test/java/org/apache/directory/scim/UserResourceTest.java
(original)
+++ directory/escimo/trunk/tests/src/test/java/org/apache/directory/scim/UserResourceTest.java
Sun Oct 20 14:13:19 2013
@@ -19,13 +19,19 @@
  */
 package org.apache.directory.scim;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
 
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.directory.api.ldap.model.constants.SchemaConstants;
+import org.apache.directory.api.ldap.model.entry.Entry;
+import org.apache.directory.api.ldap.model.name.Dn;
 import org.apache.directory.scim.User.Email;
 import org.apache.directory.scim.User.Name;
 import org.apache.directory.scim.schema.CoreResource;
@@ -38,28 +44,10 @@ import org.junit.Test;
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-//@ApplyLdifs(
-//    {
-//        "dn: uid=user1,ou=users,ou=system",
-//        "objectClass: inetOrgPerson",
-//        "sn: user1 sn",
-//        "cn: user One",
-//        "uid: user1",
-//
-//        "dn: uid=user2,ou=users,ou=system",
-//        "objectClass: inetOrgPerson",
-//        "sn: User Two",
-//        "cn: user2",
-//        "uid: user2",
-//
-//        "dn: uid=elecharny,ou=users,ou=system",
-//        "objectClass: inetOrgPerson",
-//        "sn:: RW1tYW51ZWwgTMOpY2hhcm55",
-//        "cn: elecharny",
-//        "uid: elecharny"
-//})
 public class UserResourceTest
 {
+    private static String baseUrl = "http://localhost:8080/v2";
+    
     private static EscimoClient client;
     
     @BeforeClass
@@ -70,7 +58,7 @@ public class UserResourceTest
         uriClassMap.put( Group.SCHEMA_ID, Group.class );
         uriClassMap.put( EnterpriseUser.SCHEMA_ID, EnterpriseUser.class );
         
-        client = new EscimoClient( "http://localhost:8080/v2", uriClassMap );
+        client = new EscimoClient( baseUrl, uriClassMap );
         
         JettyServer.start();
     }
@@ -205,4 +193,30 @@ public class UserResourceTest
         assertEquals( 2, patchedUser.getEmails().size() );
     }
 
+
+    @Test
+    public void testCreateGroups() throws Exception
+    {
+        Group group = new Group();
+        group.setDisplayName( "Administrator" );
+        
+        List<Group.Member> members = new ArrayList<Group.Member>();
+        group.setMembers( members );
+        
+        Entry entry = JettyServer.getAdminSession().lookup( new Dn( "uid=admin,ou=system"
), SchemaConstants.ENTRY_UUID_AT );
+        
+        Group.Member m1 = new Group.Member();
+        
+        String value = entry.get( SchemaConstants.ENTRY_UUID_AT ).getString();
+        
+        m1.setValue( value );
+        m1.set$ref( baseUrl + "/Users/" + value );
+        
+        members.add( m1 );
+        
+        Group addedGroup = ( Group ) client.addGroup( group );
+        assertNotNull( addedGroup );
+        assertEquals( group.getDisplayName(), addedGroup.getDisplayName() );
+        assertNotNull( addedGroup.getId() );
+    }
 }



Mime
View raw message