directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r718199 - /directory/sandbox/kayyagari/apacheds-olm/src/test/java/org/apache/directory/olm/PojoPersistenceTest.java
Date Mon, 17 Nov 2008 08:58:07 GMT
Author: kayyagari
Date: Mon Nov 17 00:58:06 2008
New Revision: 718199

URL: http://svn.apache.org/viewvc?rev=718199&view=rev
Log:
updated test

Modified:
    directory/sandbox/kayyagari/apacheds-olm/src/test/java/org/apache/directory/olm/PojoPersistenceTest.java

Modified: directory/sandbox/kayyagari/apacheds-olm/src/test/java/org/apache/directory/olm/PojoPersistenceTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/apacheds-olm/src/test/java/org/apache/directory/olm/PojoPersistenceTest.java?rev=718199&r1=718198&r2=718199&view=diff
==============================================================================
--- directory/sandbox/kayyagari/apacheds-olm/src/test/java/org/apache/directory/olm/PojoPersistenceTest.java
(original)
+++ directory/sandbox/kayyagari/apacheds-olm/src/test/java/org/apache/directory/olm/PojoPersistenceTest.java
Mon Nov 17 00:58:06 2008
@@ -1,6 +1,25 @@
-
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
 package org.apache.directory.olm;
 
+
 import java.io.File;
 import java.util.HashSet;
 import java.util.Set;
@@ -19,19 +38,28 @@
 import org.apache.directory.server.schema.registries.OidRegistry;
 import org.apache.directory.server.schema.registries.Registries;
 import org.apache.directory.server.unit.AbstractServerTest;
-import org.junit.Before;
 import org.junit.Test;
 
+
+/**
+ * 
+ *  PojoPersistenceTest.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
 public class PojoPersistenceTest extends AbstractServerTest
 {
+    private File wkdir;
+
 
-    @Before
+    @Override
     public void setUp() throws Exception
     {
         super.setUp();
     }
-    
-    
+
+
     @Override
     protected void configureDirectoryService() throws Exception
     {
@@ -49,37 +77,103 @@
         bootstrapSchemas.add( new InetorgpersonSchema() );
 
         loader.loadWithDependencies( bootstrapSchemas, registries );
-        
-        File wkdir = new File( System.getProperty( "java.io.tmpdir" ) + File.separator +
getClass().getSimpleName() + System.currentTimeMillis() ) ;
+
+        wkdir = new File( System.getProperty( "java.io.tmpdir" ) + File.separator + getClass().getSimpleName()
+            + System.currentTimeMillis() );
         wkdir.mkdirs();
-        
+
         directoryService.setWorkingDirectory( wkdir );
         directoryService.setRegistries( registries );
     }
-    
-    
-    @Test
-    public void testCreateInetOrgPerson() throws Exception
+
+
+    @Override
+    public void tearDown() throws Exception
+    {
+        super.tearDown();
+
+        deleteFiles( wkdir.listFiles() );
+        wkdir.delete();
+    }
+
+
+    private void deleteFiles( File[] files )
+    {
+        for ( File f : files )
+        {
+            if ( f.isDirectory() )
+            {
+                deleteFiles( f.listFiles() );
+                f.delete();
+            }
+            else
+            {
+                f.delete();
+            }
+        }
+    }
+
+
+    @Test(expected = IllegalArgumentException.class)
+    public void testAddingMultipleStructuralClasses()
     {
         InetOrgPersonEntry inetPerson = new InetOrgPersonEntry( "snJoe", "cnJoe" );
         inetPerson.getCn().addValue( "another Value for CN" );
         String dn = "cn=cnJoe,ou=system";
         inetPerson.setDN( dn );
+
+        UnixFileEntry unixFile = new UnixFileEntry( "/" );
+        try
+        {
+            inetPerson.addEntry( unixFile );
+            fail( "Should throw IllegalArgumentException" );
+        }
+        catch ( IllegalArgumentException e )
+        {
+        }
+    }
+
+
+    @Test
+    public void testCreateInetOrgPerson() throws Exception
+    {
+        InetOrgPersonEntry inetPerson = new InetOrgPersonEntry();
+        inetPerson.setCn( "cnJoe", "another Value for CN" );
+        inetPerson.setSn( "snJoe" );
+        inetPerson.setTitle( "xxx" );
         
-        LdapPersistenceUtil ldapUtil = new LdapPersistenceUtil( directoryService.getRegistries(),
directoryService.getAdminSession() );
-        ldapUtil.save( inetPerson );
+        String dn = "cn=cnJoe,ou=system";
+        inetPerson.setDN( dn );
+
+        TlsKeyInfoEntry tlsKey = new TlsKeyInfoEntry( "PKCS", "DSA", new byte[0], "keyFormat",
new byte[0] );
+        inetPerson.addEntry( tlsKey );
+
+        LdapPersistenceUtil ldapUtil = new LdapPersistenceUtil( directoryService.getRegistries(),
directoryService
+            .getAdminSession() );
+
         
+        ldapUtil.save( inetPerson );
+
         InetOrgPersonEntry entry = ( InetOrgPersonEntry ) ldapUtil.fetch( dn );
         assertNotNull( entry );
-        
+
         entry.getCn().addValue( "one more cn" );
-        entry.setTitle( "xxx" );
-        
-        ldapUtil.update( entry );
+        entry.setTitle( null );
         
+        entry.setCarLicense( "carLicense" );
+        entry.setCarLicense( "carLicense2" );
+        StoredProcUnitEntry storedProcUnit = new StoredProcUnitEntry( "procLangId", "procUnitName"
);
+        entry.addEntry( storedProcUnit );
+
+        ldapUtil.modify( entry );
+
+//        ldapUtil.delete( entry.getDN() );
+
+        /*
         while( true )
         {
             Thread.sleep( 10000 );
         }
+         */
     }
 }



Mime
View raw message