directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1669163 [3/3] - in /directory/studio/trunk/plugins/openldap.syncrepl: ./ 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/studio/ src/main/jav...
Date Wed, 25 Mar 2015 17:16:25 GMT
Added: directory/studio/trunk/plugins/openldap.syncrepl/src/test/java/com/iktek/studio/openldap/syncrepl/SyncReplParserTest.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.syncrepl/src/test/java/com/iktek/studio/openldap/syncrepl/SyncReplParserTest.java?rev=1669163&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.syncrepl/src/test/java/com/iktek/studio/openldap/syncrepl/SyncReplParserTest.java
(added)
+++ directory/studio/trunk/plugins/openldap.syncrepl/src/test/java/com/iktek/studio/openldap/syncrepl/SyncReplParserTest.java
Wed Mar 25 17:16:24 2015
@@ -0,0 +1,705 @@
+package org.apache.directory.studio.openldap.syncrepl;
+
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+
+public class SyncReplParserTest
+{
+    @Test
+    public void testEmpty() throws Exception
+    {
+        SyncReplParser parser = new SyncReplParser();
+        SyncRepl syncRepl = parser.parse( "" );
+
+        assertNull( syncRepl );
+    }
+
+
+    @Test
+    public void testUnknownOption() throws Exception
+    {
+        SyncReplParser parser = new SyncReplParser();
+        SyncRepl syncRepl = parser.parse( "unknownOption" );
+
+        assertNull( syncRepl );
+    }
+
+
+    @Test
+    public void testUnknownOptionWithValue() throws Exception
+    {
+        SyncReplParser parser = new SyncReplParser();
+        SyncRepl syncRepl = parser.parse( "unknownOption=someValue" );
+
+        assertNull( syncRepl );
+    }
+
+
+    @Test
+    public void testRidOkOneDigit() throws Exception
+    {
+        SyncReplParser parser = new SyncReplParser();
+        SyncRepl syncRepl = parser.parse( "rid=1" );
+
+        assertNotNull( syncRepl );
+        assertEquals( "1", syncRepl.getRid() );
+    }
+
+
+    @Test
+    public void testRidOkTwoDigit() throws Exception
+    {
+        SyncReplParser parser = new SyncReplParser();
+        SyncRepl syncRepl = parser.parse( "rid=12" );
+
+        assertNotNull( syncRepl );
+        assertEquals( "12", syncRepl.getRid() );
+    }
+
+
+    @Test
+    public void testRidOkThreeDigit() throws Exception
+    {
+        SyncReplParser parser = new SyncReplParser();
+        SyncRepl syncRepl = parser.parse( "rid=123" );
+
+        assertNotNull( syncRepl );
+        assertEquals( "123", syncRepl.getRid() );
+    }
+
+
+    @Test
+    public void testRidOkThreeDigitWithWhiteSpaces() throws Exception
+    {
+        SyncReplParser parser = new SyncReplParser();
+        SyncRepl syncRepl = parser.parse( "  rid = 123  " );
+
+        assertNotNull( syncRepl );
+        assertEquals( "123", syncRepl.getRid() );
+    }
+
+
+    @Test
+    public void testProvider() throws Exception
+    {
+        SyncReplParser parser = new SyncReplParser();
+        parser.parse( "provider=ldap://localhost:10389" );
+    }
+
+
+    @Test
+    public void testProviderWithWhiteSpaces() throws Exception
+    {
+        SyncReplParser parser = new SyncReplParser();
+        parser.parse( "  provider  =  ldap://localhost:10389" );
+    }
+
+
+    @Test
+    public void testSymasDoc1SingleLine() throws Exception
+    {
+        SyncReplParser parser = new SyncReplParser();
+        SyncRepl syncRepl = parser
+            .parse( "rid=0 " +
+                "provider=ldap://ldapmaster.symas.com:389 " +
+                "bindmethod=simple " +
+                "binddn=\"cn=replicator,dc=symas,dc=com\" " +
+                "credentials=secret " +
+                "searchbase=\"dc=symas,dc=com\" " +
+                "logbase=\"cn=accesslog\" " +
+                "logfilter=\"(&(objectClass=auditWriteObject)(reqResult=0))\" " +
+                "schemachecking=on " +
+                "type=refreshAndPersist " +
+                "retry=\"60 +\" " +
+                "syncdata=accesslog" );
+
+        assertNotNull( syncRepl );
+        assertEquals( "0", syncRepl.getRid() );
+
+        Provider provider = syncRepl.getProvider();
+
+        assertNotNull( provider );
+        assertFalse( provider.isLdaps() );
+        assertEquals( "ldapmaster.symas.com", provider.getHost() );
+        assertEquals( 389, provider.getPort() );
+
+        assertEquals( BindMethod.SIMPLE, syncRepl.getBindMethod() );
+        assertEquals( "cn=replicator,dc=symas,dc=com", syncRepl.getBindDn() );
+        assertEquals( "secret", syncRepl.getCredentials() );
+        assertEquals( "dc=symas,dc=com", syncRepl.getSearchBase() );
+        assertEquals( "cn=accesslog", syncRepl.getLogBase() );
+        assertEquals( "(&(objectClass=auditWriteObject)(reqResult=0))", syncRepl.getLogFilter()
);
+        assertEquals( SchemaChecking.ON, syncRepl.getSchemaChecking() );
+        assertEquals( Type.REFRESH_AND_PERSIST, syncRepl.getType() );
+
+        Retry retry = syncRepl.getRetry();
+
+        assertNotNull( retry );
+        assertEquals( 1, retry.size() );
+
+        RetryPair retryPair = retry.getPairs()[0];
+
+        assertNotNull( retryPair );
+        assertEquals( 60, retryPair.getInterval() );
+        assertEquals( RetryPair.PLUS, retryPair.getRetries() );
+
+        assertEquals( SyncData.ACCESSLOG, syncRepl.getSyncData() );
+    }
+
+
+    @Test
+    public void testSymasDoc1WithSpacesMultilines() throws Exception
+    {
+        SyncReplParser parser = new SyncReplParser();
+        SyncRepl syncRepl = parser
+            .parse( "rid=0 \n" +
+                "provider=ldap://ldapmaster.symas.com:389 \n" +
+                "bindmethod=simple \n" +
+                "binddn=\"cn=replicator,dc=symas,dc=com\" \n" +
+                "credentials=secret \n" +
+                "searchbase=\"dc=symas,dc=com\" \n" +
+                "logbase=\"cn=accesslog\" \n" +
+                "logfilter=\"(&(objectClass=auditWriteObject)(reqResult=0))\" \n" +
+                "schemachecking=on \n" +
+                "type=refreshAndPersist \n" +
+                "retry=\"60 +\" \n" +
+                "syncdata=accesslog" );
+
+        assertNotNull( syncRepl );
+        assertEquals( "0", syncRepl.getRid() );
+
+        Provider provider = syncRepl.getProvider();
+
+        assertNotNull( provider );
+        assertFalse( provider.isLdaps() );
+        assertEquals( "ldapmaster.symas.com", provider.getHost() );
+        assertEquals( 389, provider.getPort() );
+
+        assertEquals( BindMethod.SIMPLE, syncRepl.getBindMethod() );
+        assertEquals( "cn=replicator,dc=symas,dc=com", syncRepl.getBindDn() );
+        assertEquals( "secret", syncRepl.getCredentials() );
+        assertEquals( "dc=symas,dc=com", syncRepl.getSearchBase() );
+        assertEquals( "cn=accesslog", syncRepl.getLogBase() );
+        assertEquals( "(&(objectClass=auditWriteObject)(reqResult=0))", syncRepl.getLogFilter()
);
+        assertEquals( SchemaChecking.ON, syncRepl.getSchemaChecking() );
+        assertEquals( Type.REFRESH_AND_PERSIST, syncRepl.getType() );
+
+        Retry retry = syncRepl.getRetry();
+
+        assertNotNull( retry );
+        assertEquals( 1, retry.size() );
+
+        RetryPair retryPair = retry.getPairs()[0];
+
+        assertNotNull( retryPair );
+        assertEquals( 60, retryPair.getInterval() );
+        assertEquals( RetryPair.PLUS, retryPair.getRetries() );
+
+        assertEquals( SyncData.ACCESSLOG, syncRepl.getSyncData() );
+    }
+
+
+    @Test
+    public void testSymasDoc1WithoutSpacesMultilines() throws Exception
+    {
+        SyncReplParser parser = new SyncReplParser();
+        SyncRepl syncRepl = parser
+            .parse( "rid=0\n" +
+                "provider=ldap://ldapmaster.symas.com:389\n" +
+                "bindmethod=simple\n" +
+                "binddn=\"cn=replicator,dc=symas,dc=com\"\n" +
+                "credentials=secret\n" +
+                "searchbase=\"dc=symas,dc=com\"\n" +
+                "logbase=\"cn=accesslog\"\n" +
+                "logfilter=\"(&(objectClass=auditWriteObject)(reqResult=0))\"\n" +
+                "schemachecking=on\n" +
+                "type=refreshAndPersist\n" +
+                "retry=\"60 +\"\n" +
+                "syncdata=accesslog" );
+
+        assertNotNull( syncRepl );
+        assertEquals( "0", syncRepl.getRid() );
+
+        Provider provider = syncRepl.getProvider();
+
+        assertNotNull( provider );
+        assertFalse( provider.isLdaps() );
+        assertEquals( "ldapmaster.symas.com", provider.getHost() );
+        assertEquals( 389, provider.getPort() );
+
+        assertEquals( BindMethod.SIMPLE, syncRepl.getBindMethod() );
+        assertEquals( "cn=replicator,dc=symas,dc=com", syncRepl.getBindDn() );
+        assertEquals( "secret", syncRepl.getCredentials() );
+        assertEquals( "dc=symas,dc=com", syncRepl.getSearchBase() );
+        assertEquals( "cn=accesslog", syncRepl.getLogBase() );
+        assertEquals( "(&(objectClass=auditWriteObject)(reqResult=0))", syncRepl.getLogFilter()
);
+        assertEquals( SchemaChecking.ON, syncRepl.getSchemaChecking() );
+        assertEquals( Type.REFRESH_AND_PERSIST, syncRepl.getType() );
+
+        Retry retry = syncRepl.getRetry();
+
+        assertNotNull( retry );
+        assertEquals( 1, retry.size() );
+
+        RetryPair retryPair = retry.getPairs()[0];
+
+        assertNotNull( retryPair );
+        assertEquals( 60, retryPair.getInterval() );
+        assertEquals( RetryPair.PLUS, retryPair.getRetries() );
+
+        assertEquals( SyncData.ACCESSLOG, syncRepl.getSyncData() );
+    }
+
+
+    @Test
+    public void testSymasDoc2SingleLine() throws Exception
+    {
+        SyncReplParser parser = new SyncReplParser();
+        SyncRepl syncRepl = parser
+            .parse( "rid=001\n provider=ldaps://ldapmaster.symas.com:389 binddn=\"cn=config\"
bindmethod=simple credentials=secret searchbase=\"cn=config\" type=refreshAndPersist retry=\"5
5 300 5\" timeout=1" );
+
+        assertNotNull( syncRepl );
+        assertEquals( "001", syncRepl.getRid() );
+
+        Provider provider = syncRepl.getProvider();
+
+        assertNotNull( provider );
+        assertTrue( provider.isLdaps() );
+        assertEquals( "ldapmaster.symas.com", provider.getHost() );
+        assertEquals( 389, provider.getPort() );
+
+        assertEquals( BindMethod.SIMPLE, syncRepl.getBindMethod() );
+        assertEquals( "cn=config", syncRepl.getBindDn() );
+        assertEquals( "secret", syncRepl.getCredentials() );
+        assertEquals( "cn=config", syncRepl.getSearchBase() );
+
+        Retry retry = syncRepl.getRetry();
+
+        assertNotNull( retry );
+        assertEquals( 2, retry.size() );
+
+        RetryPair retryPair1 = retry.getPairs()[0];
+
+        assertNotNull( retryPair1 );
+        assertEquals( 5, retryPair1.getInterval() );
+        assertEquals( 5, retryPair1.getRetries() );
+
+        RetryPair retryPair2 = retry.getPairs()[1];
+
+        assertNotNull( retryPair2 );
+        assertEquals( 300, retryPair2.getInterval() );
+        assertEquals( 5, retryPair2.getRetries() );
+
+        assertEquals( Type.REFRESH_AND_PERSIST, syncRepl.getType() );
+        assertEquals( 1, syncRepl.getTimeout() );
+    }
+
+
+    @Test
+    public void testSymasDoc2WithSpacesMultilines() throws Exception
+    {
+        SyncReplParser parser = new SyncReplParser();
+        SyncRepl syncRepl = parser
+            .parse( "rid=001\n " +
+                "provider=ldaps://ldapmaster.symas.com:389\n " +
+                "binddn=\"cn=config\"\n " +
+                "bindmethod=simple\n " +
+                "credentials=secret\n " +
+                "searchbase=\"cn=config\"\n " +
+                "type=refreshAndPersist\n " +
+                "retry=\"5 5 300 5\"\n " +
+                "timeout=1" );
+
+        assertNotNull( syncRepl );
+        assertEquals( "001", syncRepl.getRid() );
+
+        Provider provider = syncRepl.getProvider();
+
+        assertNotNull( provider );
+        assertTrue( provider.isLdaps() );
+        assertEquals( "ldapmaster.symas.com", provider.getHost() );
+        assertEquals( 389, provider.getPort() );
+
+        assertEquals( BindMethod.SIMPLE, syncRepl.getBindMethod() );
+        assertEquals( "cn=config", syncRepl.getBindDn() );
+        assertEquals( "secret", syncRepl.getCredentials() );
+        assertEquals( "cn=config", syncRepl.getSearchBase() );
+
+        Retry retry = syncRepl.getRetry();
+
+        assertNotNull( retry );
+        assertEquals( 2, retry.size() );
+
+        RetryPair retryPair1 = retry.getPairs()[0];
+
+        assertNotNull( retryPair1 );
+        assertEquals( 5, retryPair1.getInterval() );
+        assertEquals( 5, retryPair1.getRetries() );
+
+        RetryPair retryPair2 = retry.getPairs()[1];
+
+        assertNotNull( retryPair2 );
+        assertEquals( 300, retryPair2.getInterval() );
+        assertEquals( 5, retryPair2.getRetries() );
+
+        assertEquals( Type.REFRESH_AND_PERSIST, syncRepl.getType() );
+        assertEquals( 1, syncRepl.getTimeout() );
+    }
+
+
+    @Test
+    public void testSymasDoc2WithoutSpacesMultilines() throws Exception
+    {
+        SyncReplParser parser = new SyncReplParser();
+        SyncRepl syncRepl = parser
+            .parse( "rid=001\n" +
+                "provider=ldaps://ldapmaster.symas.com:389\n" +
+                "binddn=\"cn=config\"\n" +
+                "bindmethod=simple\n" +
+                "credentials=secret\n" +
+                "searchbase=\"cn=config\"\n" +
+                "type=refreshAndPersist\n" +
+                "retry=\"5 5 300 5\"\n" +
+                "timeout=1" );
+
+        assertNotNull( syncRepl );
+        assertEquals( "001", syncRepl.getRid() );
+
+        Provider provider = syncRepl.getProvider();
+
+        assertNotNull( provider );
+        assertTrue( provider.isLdaps() );
+        assertEquals( "ldapmaster.symas.com", provider.getHost() );
+        assertEquals( 389, provider.getPort() );
+
+        assertEquals( BindMethod.SIMPLE, syncRepl.getBindMethod() );
+        assertEquals( "cn=config", syncRepl.getBindDn() );
+        assertEquals( "secret", syncRepl.getCredentials() );
+        assertEquals( "cn=config", syncRepl.getSearchBase() );
+
+        Retry retry = syncRepl.getRetry();
+
+        assertNotNull( retry );
+        assertEquals( 2, retry.size() );
+
+        RetryPair retryPair1 = retry.getPairs()[0];
+
+        assertNotNull( retryPair1 );
+        assertEquals( 5, retryPair1.getInterval() );
+        assertEquals( 5, retryPair1.getRetries() );
+
+        RetryPair retryPair2 = retry.getPairs()[1];
+
+        assertNotNull( retryPair2 );
+        assertEquals( 300, retryPair2.getInterval() );
+        assertEquals( 5, retryPair2.getRetries() );
+
+        assertEquals( Type.REFRESH_AND_PERSIST, syncRepl.getType() );
+        assertEquals( 1, syncRepl.getTimeout() );
+    }
+
+
+    @Test
+    public void testSymasDoc3SingleLine() throws Exception
+    {
+        SyncReplParser parser = new SyncReplParser();
+        SyncRepl syncRepl = parser
+            .parse( "rid=123 " +
+                "provider=ldap://provider.example.com:389 " +
+                "type=refreshOnly " +
+                "interval=01:00:00:00 " +
+                "searchbase=\"dc=example,dc=com\" " +
+                "filter=\"(objectClass=organizationalPerson)\" " +
+                "scope=sub " +
+                "attrs=\"cn,sn,ou,telephoneNumber,title,l\" " +
+                "schemachecking=off " +
+                "bindmethod=simple " +
+                "binddn=\"cn=syncuser,dc=example,dc=com\" " +
+                "credentials=secret" );
+
+        assertNotNull( syncRepl );
+        assertEquals( "123", syncRepl.getRid() );
+
+        Provider provider = syncRepl.getProvider();
+
+        assertNotNull( provider );
+        assertFalse( provider.isLdaps() );
+        assertEquals( "provider.example.com", provider.getHost() );
+        assertEquals( 389, provider.getPort() );
+
+        assertEquals( Type.REFRESH_ONLY, syncRepl.getType() );
+
+        Interval interval = syncRepl.getInterval();
+
+        assertNotNull( interval );
+        assertEquals( 1, interval.getDays() );
+        assertEquals( 0, interval.getHours() );
+        assertEquals( 0, interval.getMinutes() );
+        assertEquals( 0, interval.getSeconds() );
+
+        assertEquals( "dc=example,dc=com", syncRepl.getSearchBase() );
+        assertEquals( "(objectClass=organizationalPerson)", syncRepl.getFilter() );
+        assertEquals( Scope.SUB, syncRepl.getScope() );
+
+        String[] attributes = syncRepl.getAttributes();
+
+        assertNotNull( attributes );
+        assertEquals( 6, attributes.length );
+        assertEquals( "cn", attributes[0] );
+        assertEquals( "sn", attributes[1] );
+        assertEquals( "ou", attributes[2] );
+        assertEquals( "telephoneNumber", attributes[3] );
+        assertEquals( "title", attributes[4] );
+        assertEquals( "l", attributes[5] );
+
+        assertEquals( SchemaChecking.OFF, syncRepl.getSchemaChecking() );
+        assertEquals( BindMethod.SIMPLE, syncRepl.getBindMethod() );
+        assertEquals( "cn=syncuser,dc=example,dc=com", syncRepl.getBindDn() );
+        assertEquals( "secret", syncRepl.getCredentials() );
+    }
+
+
+    @Test
+    public void testSymasDoc3WithoutSpacesMultilines() throws Exception
+    {
+        SyncReplParser parser = new SyncReplParser();
+        SyncRepl syncRepl = parser
+            .parse( "rid=123\n" +
+                "provider=ldap://provider.example.com:389\n" +
+                "type=refreshOnly\n" +
+                "interval=01:00:00:00\n" +
+                "searchbase=\"dc=example,dc=com\"\n" +
+                "filter=\"(objectClass=organizationalPerson)\"\n" +
+                "scope=sub\n" +
+                "attrs=\"cn,sn,ou,telephoneNumber,title,l\"\n" +
+                "schemachecking=off\n" +
+                "bindmethod=simple\n" +
+                "binddn=\"cn=syncuser,dc=example,dc=com\"\n" +
+                "credentials=secret" );
+
+        assertNotNull( syncRepl );
+        assertEquals( "123", syncRepl.getRid() );
+
+        Provider provider = syncRepl.getProvider();
+
+        assertNotNull( provider );
+        assertFalse( provider.isLdaps() );
+        assertEquals( "provider.example.com", provider.getHost() );
+        assertEquals( 389, provider.getPort() );
+
+        assertEquals( Type.REFRESH_ONLY, syncRepl.getType() );
+
+        Interval interval = syncRepl.getInterval();
+
+        assertNotNull( interval );
+        assertEquals( 1, interval.getDays() );
+        assertEquals( 0, interval.getHours() );
+        assertEquals( 0, interval.getMinutes() );
+        assertEquals( 0, interval.getSeconds() );
+
+        assertEquals( "dc=example,dc=com", syncRepl.getSearchBase() );
+        assertEquals( "(objectClass=organizationalPerson)", syncRepl.getFilter() );
+        assertEquals( Scope.SUB, syncRepl.getScope() );
+
+        String[] attributes = syncRepl.getAttributes();
+
+        assertNotNull( attributes );
+        assertEquals( 6, attributes.length );
+        assertEquals( "cn", attributes[0] );
+        assertEquals( "sn", attributes[1] );
+        assertEquals( "ou", attributes[2] );
+        assertEquals( "telephoneNumber", attributes[3] );
+        assertEquals( "title", attributes[4] );
+        assertEquals( "l", attributes[5] );
+
+        assertEquals( SchemaChecking.OFF, syncRepl.getSchemaChecking() );
+        assertEquals( BindMethod.SIMPLE, syncRepl.getBindMethod() );
+        assertEquals( "cn=syncuser,dc=example,dc=com", syncRepl.getBindDn() );
+        assertEquals( "secret", syncRepl.getCredentials() );
+    }
+
+
+    @Test
+    public void testSymasDoc3WithSpacesMultilines() throws Exception
+    {
+        SyncReplParser parser = new SyncReplParser();
+        SyncRepl syncRepl = parser
+            .parse( "rid=123 \n" +
+                "provider=ldap://provider.example.com:389 \n" +
+                "type=refreshOnly \n" +
+                "interval=01:00:00:00 \n" +
+                "searchbase=\"dc=example,dc=com\" \n" +
+                "filter=\"(objectClass=organizationalPerson)\" \n" +
+                "scope=sub \n" +
+                "attrs=\"cn,sn,ou,telephoneNumber,title,l\" \n" +
+                "schemachecking=off \n" +
+                "bindmethod=simple \n" +
+                "binddn=\"cn=syncuser,dc=example,dc=com\" \n" +
+                "credentials=secret" );
+
+        assertNotNull( syncRepl );
+        assertEquals( "123", syncRepl.getRid() );
+
+        Provider provider = syncRepl.getProvider();
+
+        assertNotNull( provider );
+        assertFalse( provider.isLdaps() );
+        assertEquals( "provider.example.com", provider.getHost() );
+        assertEquals( 389, provider.getPort() );
+
+        assertEquals( Type.REFRESH_ONLY, syncRepl.getType() );
+
+        Interval interval = syncRepl.getInterval();
+
+        assertNotNull( interval );
+        assertEquals( 1, interval.getDays() );
+        assertEquals( 0, interval.getHours() );
+        assertEquals( 0, interval.getMinutes() );
+        assertEquals( 0, interval.getSeconds() );
+
+        assertEquals( "dc=example,dc=com", syncRepl.getSearchBase() );
+        assertEquals( "(objectClass=organizationalPerson)", syncRepl.getFilter() );
+        assertEquals( Scope.SUB, syncRepl.getScope() );
+
+        String[] attributes = syncRepl.getAttributes();
+
+        assertNotNull( attributes );
+        assertEquals( 6, attributes.length );
+        assertEquals( "cn", attributes[0] );
+        assertEquals( "sn", attributes[1] );
+        assertEquals( "ou", attributes[2] );
+        assertEquals( "telephoneNumber", attributes[3] );
+        assertEquals( "title", attributes[4] );
+        assertEquals( "l", attributes[5] );
+
+        assertEquals( SchemaChecking.OFF, syncRepl.getSchemaChecking() );
+        assertEquals( BindMethod.SIMPLE, syncRepl.getBindMethod() );
+        assertEquals( "cn=syncuser,dc=example,dc=com", syncRepl.getBindDn() );
+        assertEquals( "secret", syncRepl.getCredentials() );
+    }
+
+
+    @Test
+    public void testSymasDoc3WithSpacesMultilinesAllQuoted() throws Exception
+    {
+        SyncReplParser parser = new SyncReplParser();
+        SyncRepl syncRepl = parser
+            .parse( "rid=\"123\" \n" +
+                "provider=\"ldap://provider.example.com:389\" \n" +
+                "type=\"refreshOnly\" \n" +
+                "interval=\"01:00:00:00\" \n" +
+                "searchbase=\"dc=example,dc=com\" \n" +
+                "filter=\"(objectClass=organizationalPerson)\" \n" +
+                "scope=\"sub\" \n" +
+                "attrs=\"cn,sn,ou,telephoneNumber,title,l\" \n" +
+                "schemachecking=\"off\" \n" +
+                "bindmethod=\"simple\" \n" +
+                "binddn=\"cn=syncuser,dc=example,dc=com\" \n" +
+                "credentials=\"secret\"" );
+
+        assertNotNull( syncRepl );
+        assertEquals( "123", syncRepl.getRid() );
+
+        Provider provider = syncRepl.getProvider();
+
+        assertNotNull( provider );
+        assertFalse( provider.isLdaps() );
+        assertEquals( "provider.example.com", provider.getHost() );
+        assertEquals( 389, provider.getPort() );
+
+        assertEquals( Type.REFRESH_ONLY, syncRepl.getType() );
+
+        Interval interval = syncRepl.getInterval();
+
+        assertNotNull( interval );
+        assertEquals( 1, interval.getDays() );
+        assertEquals( 0, interval.getHours() );
+        assertEquals( 0, interval.getMinutes() );
+        assertEquals( 0, interval.getSeconds() );
+
+        assertEquals( "dc=example,dc=com", syncRepl.getSearchBase() );
+        assertEquals( "(objectClass=organizationalPerson)", syncRepl.getFilter() );
+        assertEquals( Scope.SUB, syncRepl.getScope() );
+
+        String[] attributes = syncRepl.getAttributes();
+
+        assertNotNull( attributes );
+        assertEquals( 6, attributes.length );
+        assertEquals( "cn", attributes[0] );
+        assertEquals( "sn", attributes[1] );
+        assertEquals( "ou", attributes[2] );
+        assertEquals( "telephoneNumber", attributes[3] );
+        assertEquals( "title", attributes[4] );
+        assertEquals( "l", attributes[5] );
+
+        assertEquals( SchemaChecking.OFF, syncRepl.getSchemaChecking() );
+        assertEquals( BindMethod.SIMPLE, syncRepl.getBindMethod() );
+        assertEquals( "cn=syncuser,dc=example,dc=com", syncRepl.getBindDn() );
+        assertEquals( "secret", syncRepl.getCredentials() );
+    }
+    @Test
+    public void testSymasDoc3WithSpacesMultilinesAllNotQuoted() throws Exception
+    {
+        SyncReplParser parser = new SyncReplParser();
+        SyncRepl syncRepl = parser
+            .parse( "rid=123 \n" +
+                "provider=ldap://provider.example.com:389 \n" +
+                "type=refreshOnly \n" +
+                "interval=01:00:00:00 \n" +
+                "searchbase=dc=example,dc=com \n" +
+                "filter=(objectClass=organizationalPerson) \n" +
+                "scope=sub \n" +
+                "attrs=cn,sn,ou,telephoneNumber,title,l \n" +
+                "schemachecking=off \n" +
+                "bindmethod=simple \n" +
+                "binddn=cn=syncuser,dc=example,dc=com \n" +
+                "credentials=secret" );
+
+        assertNotNull( syncRepl );
+        assertEquals( "123", syncRepl.getRid() );
+
+        Provider provider = syncRepl.getProvider();
+
+        assertNotNull( provider );
+        assertFalse( provider.isLdaps() );
+        assertEquals( "provider.example.com", provider.getHost() );
+        assertEquals( 389, provider.getPort() );
+
+        assertEquals( Type.REFRESH_ONLY, syncRepl.getType() );
+
+        Interval interval = syncRepl.getInterval();
+
+        assertNotNull( interval );
+        assertEquals( 1, interval.getDays() );
+        assertEquals( 0, interval.getHours() );
+        assertEquals( 0, interval.getMinutes() );
+        assertEquals( 0, interval.getSeconds() );
+
+        assertEquals( "dc=example,dc=com", syncRepl.getSearchBase() );
+        assertEquals( "(objectClass=organizationalPerson)", syncRepl.getFilter() );
+        assertEquals( Scope.SUB, syncRepl.getScope() );
+
+        String[] attributes = syncRepl.getAttributes();
+
+        assertNotNull( attributes );
+        assertEquals( 6, attributes.length );
+        assertEquals( "cn", attributes[0] );
+        assertEquals( "sn", attributes[1] );
+        assertEquals( "ou", attributes[2] );
+        assertEquals( "telephoneNumber", attributes[3] );
+        assertEquals( "title", attributes[4] );
+        assertEquals( "l", attributes[5] );
+
+        assertEquals( SchemaChecking.OFF, syncRepl.getSchemaChecking() );
+        assertEquals( BindMethod.SIMPLE, syncRepl.getBindMethod() );
+        assertEquals( "cn=syncuser,dc=example,dc=com", syncRepl.getBindDn() );
+        assertEquals( "secret", syncRepl.getCredentials() );
+    }
+}



Mime
View raw message