You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ka...@apache.org on 2008/10/22 20:07:54 UTC
svn commit: r707152 [2/2] - in /directory/sandbox/kayyagari/apacheds-olm: ./
src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/
src/main/java/org/apache/directory/ src/main/java/org/apache/directory/olm/
src/main/java/org/apache...
Added: 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=707152&view=auto
==============================================================================
--- directory/sandbox/kayyagari/apacheds-olm/src/test/java/org/apache/directory/olm/PojoPersistenceTest.java (added)
+++ directory/sandbox/kayyagari/apacheds-olm/src/test/java/org/apache/directory/olm/PojoPersistenceTest.java Wed Oct 22 11:07:53 2008
@@ -0,0 +1,85 @@
+
+package org.apache.directory.olm;
+
+import java.io.File;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.directory.olm.util.LdapPersistenceUtil;
+import org.apache.directory.server.schema.SerializableComparator;
+import org.apache.directory.server.schema.bootstrap.ApacheSchema;
+import org.apache.directory.server.schema.bootstrap.ApachemetaSchema;
+import org.apache.directory.server.schema.bootstrap.BootstrapSchemaLoader;
+import org.apache.directory.server.schema.bootstrap.CoreSchema;
+import org.apache.directory.server.schema.bootstrap.InetorgpersonSchema;
+import org.apache.directory.server.schema.bootstrap.Schema;
+import org.apache.directory.server.schema.bootstrap.SystemSchema;
+import org.apache.directory.server.schema.registries.DefaultOidRegistry;
+import org.apache.directory.server.schema.registries.DefaultRegistries;
+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;
+
+public class PojoPersistenceTest extends AbstractServerTest
+{
+
+ @Before
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ }
+
+
+ @Override
+ protected void configureDirectoryService() throws Exception
+ {
+ BootstrapSchemaLoader loader = new BootstrapSchemaLoader();
+ OidRegistry oidRegistry = new DefaultOidRegistry();
+ Registries registries = new DefaultRegistries( "bootstrap", loader, oidRegistry );
+ SerializableComparator.setRegistry( registries.getComparatorRegistry() );
+
+ // load essential bootstrap schemas
+ Set<Schema> bootstrapSchemas = new HashSet<Schema>();
+ bootstrapSchemas.add( new ApachemetaSchema() );
+ bootstrapSchemas.add( new ApacheSchema() );
+ bootstrapSchemas.add( new CoreSchema() );
+ bootstrapSchemas.add( new SystemSchema() );
+ bootstrapSchemas.add( new InetorgpersonSchema() );
+
+ loader.loadWithDependencies( bootstrapSchemas, registries );
+
+ File 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
+ {
+ InetOrgPersonEntry inetPerson = new InetOrgPersonEntry( "snJoe", "cnJoe" );
+ inetPerson.getCn().addValue( "another Value for CN" );
+ String dn = "cn=cnJoe,ou=system";
+ inetPerson.setDN( dn );
+
+ 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 );
+
+ while( true )
+ {
+ Thread.sleep( 10000 );
+ }
+ }
+}
Added: directory/sandbox/kayyagari/apacheds-olm/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/apacheds-olm/src/test/resources/log4j.properties?rev=707152&view=auto
==============================================================================
--- directory/sandbox/kayyagari/apacheds-olm/src/test/resources/log4j.properties (added)
+++ directory/sandbox/kayyagari/apacheds-olm/src/test/resources/log4j.properties Wed Oct 22 11:07:53 2008
@@ -0,0 +1,23 @@
+#############################################################################
+# 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.
+#############################################################################
+#log4j.rootCategory=DEBUG, stdout
+log4j.rootCategory=WARN, stdout
+
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=[%d{HH:mm:ss}] %p [%c] - %m%n
+