directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r489427 - in /directory/trunks/shared/ldap/src: main/java/org/apache/directory/shared/ldap/schema/syntax/ test/java/org/apache/directory/shared/ldap/schema/syntax/
Date Thu, 21 Dec 2006 18:17:34 GMT
Author: elecharny
Date: Thu Dec 21 10:17:33 2006
New Revision: 489427

URL: http://svn.apache.org/viewvc?view=rev&rev=489427
Log:
5 more syntax checkers added, and tests... 13 more to go

Added:
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/AccessPointSyntaxChecker.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/DLSubmitPermissionSyntaxChecker.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/DSAQualitySyntaxSyntaxChecker.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/DSETypeSyntaxChecker.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/DataQualitySyntaxSyntaxChecker.java
    directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/AccessPointSyntaxCheckerTest.java
    directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/DLSubmitPermissionSyntaxCheckerTest.java
    directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/DSAQualitySyntaxSyntaxCheckerTest.java
    directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/DSETypeSyntaxCheckerTest.java
    directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/DataQualitySyntaxSyntaxCheckerTest.java

Added: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/AccessPointSyntaxChecker.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/AccessPointSyntaxChecker.java?view=auto&rev=489427
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/AccessPointSyntaxChecker.java
(added)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/AccessPointSyntaxChecker.java
Thu Dec 21 10:17:33 2006
@@ -0,0 +1,62 @@
+/*
+ *  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.shared.ldap.schema.syntax;
+
+
+/**
+ * A SyntaxChecker which verifies that a value is an AccessPoint.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: 488616 $
+ */
+public class AccessPointSyntaxChecker extends AbstractSyntaxChecker
+{
+    /** the Apache assigned internal OID for this syntax checker */
+    private static final String SC_OID = "1.3.6.1.4.1.1466.115.121.1.2";
+
+
+    /**
+     * Private default constructor to prevent unnecessary instantiation.
+     */
+    public AccessPointSyntaxChecker()
+    {
+        super( SC_OID );
+    }
+
+    /**
+     * 
+     * Creates a new instance of AccessPointSyntaxChecker.
+     * 
+     * @param the oid to associate with this new SyntaxChecker
+     *
+     */
+    protected AccessPointSyntaxChecker( String oid )
+    {
+        super( oid );
+    }
+    
+    /**
+     * @see org.apache.directory.shared.ldap.schema.syntax.SyntaxChecker#isValidSyntax(Object)
+     */
+    public boolean isValidSyntax( Object value )
+    {
+        return true;
+    }
+}

Added: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/DLSubmitPermissionSyntaxChecker.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/DLSubmitPermissionSyntaxChecker.java?view=auto&rev=489427
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/DLSubmitPermissionSyntaxChecker.java
(added)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/DLSubmitPermissionSyntaxChecker.java
Thu Dec 21 10:17:33 2006
@@ -0,0 +1,62 @@
+/*
+ *  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.shared.ldap.schema.syntax;
+
+
+/**
+ * A SyntaxChecker which verifies that a value is a DLSubmitPermission.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: 488616 $
+ */
+public class DLSubmitPermissionSyntaxChecker extends AbstractSyntaxChecker
+{
+    /** the Apache assigned internal OID for this syntax checker */
+    private static final String SC_OID = "1.3.6.1.4.1.1466.115.121.1.18";
+
+
+    /**
+     * Private default constructor to prevent unnecessary instantiation.
+     */
+    public DLSubmitPermissionSyntaxChecker()
+    {
+        super( SC_OID );
+    }
+
+    /**
+     * 
+     * Creates a new instance of DLSubmitPermissionSyntaxChecker.
+     * 
+     * @param the oid to associate with this new SyntaxChecker
+     *
+     */
+    protected DLSubmitPermissionSyntaxChecker( String oid )
+    {
+        super( oid );
+    }
+    
+    /**
+     * @see org.apache.directory.shared.ldap.schema.syntax.SyntaxChecker#isValidSyntax(Object)
+     */
+    public boolean isValidSyntax( Object value )
+    {
+        return true;
+    }
+}

Added: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/DSAQualitySyntaxSyntaxChecker.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/DSAQualitySyntaxSyntaxChecker.java?view=auto&rev=489427
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/DSAQualitySyntaxSyntaxChecker.java
(added)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/DSAQualitySyntaxSyntaxChecker.java
Thu Dec 21 10:17:33 2006
@@ -0,0 +1,168 @@
+/*
+ *  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.shared.ldap.schema.syntax;
+
+
+import org.apache.directory.shared.ldap.util.StringTools;
+
+
+/**
+ * A SyntaxChecker which verifies that a value is a DSAQualitySyntax according to 
+ * http://tools.ietf.org/id/draft-ietf-asid-ldapv3-attributes-03.txt, par 5.2.2.2 :
+ * 
+ * <DsaQualitySyntax> ::= <DSAKeyword> [ '#' <description> ]
+ *
+ * <DSAKeyword> ::= 'DEFUNCT' | 'EXPERIMENTAL' | 'BEST-EFFORT' |
+ *                  'PILOT-SERVICE' | 'FULL-SERVICE'
+ *
+ * <description> ::= encoded as a PrintableString
+ * 
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class DSAQualitySyntaxSyntaxChecker extends PrintableStringSyntaxChecker
+{
+    /** The Syntax OID, according to RFC 2252 */
+    private static final String SC_OID = "1.3.6.1.4.1.1466.115.121.1.19";
+    
+    /**
+     * 
+     * Creates a new instance of DSAQualitySyntaxSyntaxChecker.
+     *
+     */
+    public DSAQualitySyntaxSyntaxChecker()
+    {
+        super( SC_OID );
+    }
+    
+    /**
+     * 
+     * Creates a new instance of DSAQualitySyntaxSyntaxChecker.
+     * 
+     * @param the oid to associate with this new SyntaxChecker
+     *
+     */
+    protected DSAQualitySyntaxSyntaxChecker( String oid )
+    {
+        super( oid );
+    }
+    
+    
+    /* (non-Javadoc)
+     * @see org.apache.directory.shared.ldap.schema.SyntaxChecker#isValidSyntax(java.lang.Object)
+     */
+    public boolean isValidSyntax( Object value )
+    {
+        String strValue;
+
+        if ( value == null )
+        {
+            return false;
+        }
+        
+        if ( value instanceof String )
+        {
+            strValue = ( String ) value;
+        }
+        else if ( value instanceof byte[] )
+        {
+            strValue = StringTools.utf8ToString( ( byte[] ) value ); 
+        }
+        else
+        {
+            strValue = value.toString();
+        }
+
+        if ( strValue.length() < 7 )
+        {
+            return false;
+        }
+
+        String remaining = null;
+        
+        switch ( strValue.charAt( 0 ) )
+        {
+            case 'B' :
+                if ( !strValue.startsWith( "BEST-EFFORT" ) )
+                {
+                    return false;
+                }
+                
+                remaining = strValue.substring( "BEST-EFFORT".length() );
+                break;
+                
+            case 'D' :
+                if ( !strValue.startsWith( "DEFUNCT" ) )
+                {
+                    return false;
+                }
+                
+                remaining = strValue.substring( "DEFUNCT".length() );
+                break;
+                
+            case 'E' :
+                if ( !strValue.startsWith( "EXPERIMENTAL" ) )
+                {
+                    return false;
+                }
+                
+                remaining = strValue.substring( "EXPERIMENTAL".length() );
+                break;
+                
+            case 'F' :
+                if ( !strValue.startsWith( "FULL-SERVICE" ) )
+                {
+                    return false;
+                }
+                
+                remaining = strValue.substring( "FULL-SERVICE".length() );
+                break;
+                
+            case 'P' :
+                if ( !strValue.startsWith( "PILOT-SERVICE" ) )
+                {
+                    return false;
+                }
+                
+                remaining = strValue.substring( "PILOT-SERVICE".length() );
+                break;
+                
+            default :
+                return false;
+        }
+        
+        // Now, we might have a description separated from the keyword by a '#'
+        // but this is optional
+        if ( remaining.length() == 0 )
+        {
+            return true;
+        }
+        
+        if ( remaining.charAt( 0 ) != '#' )
+        {
+            // We were expecting a '#'
+            return false;
+        }
+        
+        // Check that the description is a PrintableString
+        return super.isValidSyntax( remaining.substring( 1 ) );
+    }
+}

Added: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/DSETypeSyntaxChecker.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/DSETypeSyntaxChecker.java?view=auto&rev=489427
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/DSETypeSyntaxChecker.java
(added)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/DSETypeSyntaxChecker.java
Thu Dec 21 10:17:33 2006
@@ -0,0 +1,195 @@
+/*
+ *  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.shared.ldap.schema.syntax;
+
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.directory.shared.ldap.util.StringTools;
+
+
+/**
+ * A SyntaxChecker which verifies that a value is a DSEType according to 
+ * http://tools.ietf.org/id/draft-ietf-asid-ldapv3-attributes-03.txt, par 6.2.1.5 :
+ * 
+ * <DSEType>    ::= '(' <sp>* <DSEBit> <sp>* <DSEBitList> ')'
+ * <DSEBitList> ::= '$' <sp>* <DSEBit> <sp>* <DSEBitList> |
e      
+ * <DSEBit>     ::= 'root' | 'glue' | 'cp' | 'entry' | 'alias' | 'subr' |
+ *                  'nssr' | 'supr' | 'xr' | 'admPoint' | 'subentry' |
+ *                  'shadow' | 'zombie' | 'immSupr' | 'rhob' | 'sa'
+ * 
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class DSETypeSyntaxChecker extends AbstractSyntaxChecker
+{
+    /** The Syntax OID, according to RFC 2252 */
+    private static final String SC_OID = "1.3.6.1.4.1.1466.115.121.1.20";
+    
+    /** The DSE BITS keywords */
+    private static final String[] DSE_BITS_STRINGS = 
+        {
+        "root", "glue", "cp", "entry", "alias", "subr",
+        "nssr", "supr", "xr", "admPoint", "subentry",
+        "shadow", "zombie", "immSupr", "rhob", "sa"
+        };
+    
+    
+    /** The Set which contains the DESBits */
+    private final static Set<String> DSE_BITS = new HashSet<String>();
+    
+    /** Initialization of the country set */
+    static
+    {
+        for ( String country:DSE_BITS_STRINGS )
+        {
+            DSE_BITS.add( country );
+        }
+    }
+
+    
+    /**
+     * 
+     * Creates a new instance of DSETypeSyntaxChecker.
+     *
+     */
+    public DSETypeSyntaxChecker()
+    {
+        super( SC_OID );
+    }
+    
+    /**
+     * 
+     * Creates a new instance of DSETypeSyntaxChecker.
+     * 
+     * @param the oid to associate with this new SyntaxChecker
+     *
+     */
+    protected DSETypeSyntaxChecker( String oid )
+    {
+        super( oid );
+    }
+    
+    
+    /* (non-Javadoc)
+     * @see org.apache.directory.shared.ldap.schema.SyntaxChecker#isValidSyntax(java.lang.Object)
+     */
+    public boolean isValidSyntax( Object value )
+    {
+        String strValue;
+
+        if ( value == null )
+        {
+            return false;
+        }
+        
+        if ( value instanceof String )
+        {
+            strValue = ( String ) value;
+        }
+        else if ( value instanceof byte[] )
+        {
+            strValue = StringTools.utf8ToString( ( byte[] ) value ); 
+        }
+        else
+        {
+            strValue = value.toString();
+        }
+
+        // We must have at least '(cp)', '(xr)' or '(ca)'
+        if ( strValue.length() < 4 )
+        {
+            return false;
+        }
+
+        // Check the opening and closing parenthesis
+        if ( ( strValue.charAt( 0 ) != '(' ) || 
+             ( strValue.charAt( strValue.length() - 1 ) != ')' ) )
+        {
+            return false;
+        }
+
+        Set<String> keywords = new HashSet<String>();
+        int len = strValue.length() - 1;
+        boolean needKeyword = true;
+        
+        // 
+        for ( int i = 1; i < len; /* */ )
+        {
+            // Skip spaces
+            while ( ( i < len ) && ( strValue.charAt( i ) == ' ' ) )
+            {
+                i++;
+            }
+            
+            int pos = i;
+            
+            // Search for a keyword
+            while ( ( i < len ) && StringTools.isAlphaASCII( strValue, pos ) )
+            {
+                pos++;
+            }
+            
+            if ( pos == i )
+            {
+                // No keyword : error
+                return false;
+            }
+            
+            String keyword = strValue.substring( i, pos );
+            i = pos;
+            
+            if ( DSE_BITS.contains( keyword ) == false )
+            {
+                // Unkown keyword
+                return false;
+            }
+            
+            // Check that the keyword has not been met
+            if ( keywords.contains( keyword ) )
+            {
+                return false;
+            }
+            
+            keywords.add( keyword );
+            needKeyword = false;
+            
+            // Skip spaces
+            while ( ( i < len ) && ( strValue.charAt( i ) == ' ' ) )
+            {
+                i++;
+            }
+            
+            // Do we have another keyword ?
+            if ( ( i < len) && ( strValue.charAt( i ) == '$' ) )
+            {
+                // yes
+                i++;
+                needKeyword = true;
+                continue;
+            }
+        }
+        
+        // We are done
+        return !needKeyword;
+    }
+}

Added: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/DataQualitySyntaxSyntaxChecker.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/DataQualitySyntaxSyntaxChecker.java?view=auto&rev=489427
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/DataQualitySyntaxSyntaxChecker.java
(added)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/DataQualitySyntaxSyntaxChecker.java
Thu Dec 21 10:17:33 2006
@@ -0,0 +1,62 @@
+/*
+ *  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.shared.ldap.schema.syntax;
+
+
+/**
+ * A SyntaxChecker which verifies that a value is a DataQualitySyntax.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: 488616 $
+ */
+public class DataQualitySyntaxSyntaxChecker extends AbstractSyntaxChecker
+{
+    /** the Apache assigned internal OID for this syntax checker */
+    private static final String SC_OID = "1.3.6.1.4.1.1466.115.121.1.13";
+
+
+    /**
+     * Private default constructor to prevent unnecessary instantiation.
+     */
+    public DataQualitySyntaxSyntaxChecker()
+    {
+        super( SC_OID );
+    }
+
+    /**
+     * 
+     * Creates a new instance of DataQualitySyntaxSyntaxChecker.
+     * 
+     * @param the oid to associate with this new SyntaxChecker
+     *
+     */
+    protected DataQualitySyntaxSyntaxChecker( String oid )
+    {
+        super( oid );
+    }
+    
+    /**
+     * @see org.apache.directory.shared.ldap.schema.syntax.SyntaxChecker#isValidSyntax(Object)
+     */
+    public boolean isValidSyntax( Object value )
+    {
+        return true;
+    }
+}

Added: directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/AccessPointSyntaxCheckerTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/AccessPointSyntaxCheckerTest.java?view=auto&rev=489427
==============================================================================
--- directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/AccessPointSyntaxCheckerTest.java
(added)
+++ directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/AccessPointSyntaxCheckerTest.java
Thu Dec 21 10:17:33 2006
@@ -0,0 +1,56 @@
+/*
+ *  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.shared.ldap.schema.syntax;
+
+import junit.framework.TestCase;
+
+/**
+ * Test cases for AccessPointSyntaxChecker.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class AccessPointSyntaxCheckerTest extends TestCase
+{
+    AccessPointSyntaxChecker checker = new AccessPointSyntaxChecker();
+
+
+    public void testNullString()
+    {
+        assertTrue( checker.isValidSyntax( null ) );
+    }
+
+
+    public void testEmptyString()
+    {
+        assertTrue( checker.isValidSyntax( "" ) );
+    }
+
+    public void testOid()
+    {
+        assertEquals( "1.3.6.1.4.1.1466.115.121.1.2", checker.getSyntaxOid() );
+    }
+
+    public void testCorrectCase()
+    {
+        assertTrue( checker.isValidSyntax( "FALSE" ) );
+        assertTrue( checker.isValidSyntax( new byte[]{0x01, (byte)0xFF} ) );
+    }
+}

Added: directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/DLSubmitPermissionSyntaxCheckerTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/DLSubmitPermissionSyntaxCheckerTest.java?view=auto&rev=489427
==============================================================================
--- directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/DLSubmitPermissionSyntaxCheckerTest.java
(added)
+++ directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/DLSubmitPermissionSyntaxCheckerTest.java
Thu Dec 21 10:17:33 2006
@@ -0,0 +1,56 @@
+/*
+ *  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.shared.ldap.schema.syntax;
+
+import junit.framework.TestCase;
+
+/**
+ * Test cases for DLSubmitPermissionSyntaxChecker.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class DLSubmitPermissionSyntaxCheckerTest extends TestCase
+{
+    DLSubmitPermissionSyntaxChecker checker = new DLSubmitPermissionSyntaxChecker();
+
+
+    public void testNullString()
+    {
+        assertTrue( checker.isValidSyntax( null ) );
+    }
+
+
+    public void testEmptyString()
+    {
+        assertTrue( checker.isValidSyntax( "" ) );
+    }
+
+    public void testOid()
+    {
+        assertEquals( "1.3.6.1.4.1.1466.115.121.1.18", checker.getSyntaxOid() );
+    }
+
+    public void testCorrectCase()
+    {
+        assertTrue( checker.isValidSyntax( "FALSE" ) );
+        assertTrue( checker.isValidSyntax( new byte[]{0x01, (byte)0xFF} ) );
+    }
+}

Added: directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/DSAQualitySyntaxSyntaxCheckerTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/DSAQualitySyntaxSyntaxCheckerTest.java?view=auto&rev=489427
==============================================================================
--- directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/DSAQualitySyntaxSyntaxCheckerTest.java
(added)
+++ directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/DSAQualitySyntaxSyntaxCheckerTest.java
Thu Dec 21 10:17:33 2006
@@ -0,0 +1,67 @@
+/*
+ *  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.shared.ldap.schema.syntax;
+
+import junit.framework.TestCase;
+
+/**
+ * Test cases for DSAQualitySyntaxSyntaxChecker.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class DSAQualitySyntaxSyntaxCheckerTest extends TestCase
+{
+    DSAQualitySyntaxSyntaxChecker checker = new DSAQualitySyntaxSyntaxChecker();
+
+
+    public void testNullString()
+    {
+        assertFalse( checker.isValidSyntax( null ) );
+    }
+
+
+    public void testEmptyString()
+    {
+        assertFalse( checker.isValidSyntax( "" ) );
+    }
+
+
+    public void testWrongCase()
+    {
+        assertFalse( checker.isValidSyntax( "Bad" ) );
+        assertFalse( checker.isValidSyntax( "DEFuNCT" ) );
+        assertFalse( checker.isValidSyntax( " DEFUNCT" ) );
+        assertFalse( checker.isValidSyntax( "DEFUNCT$desc" ) );
+        assertFalse( checker.isValidSyntax( "DEFUNCT#" ) );
+        assertFalse( checker.isValidSyntax( "EXPERIMENTAL#test @ bad <desc>" ) );
+    }
+    
+    
+    public void testCorrectCase()
+    {
+        assertTrue( checker.isValidSyntax( "DEFUNCT" ) );
+        assertTrue( checker.isValidSyntax( "EXPERIMENTAL" ) );
+        assertTrue( checker.isValidSyntax( "BEST-EFFORT" ) );
+        assertTrue( checker.isValidSyntax( "PILOT-SERVICE" ) );
+        assertTrue( checker.isValidSyntax( "FULL-SERVICE" ) );
+        assertTrue( checker.isValidSyntax( "EXPERIMENTAL#test desc" ) );
+    }
+}

Added: directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/DSETypeSyntaxCheckerTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/DSETypeSyntaxCheckerTest.java?view=auto&rev=489427
==============================================================================
--- directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/DSETypeSyntaxCheckerTest.java
(added)
+++ directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/DSETypeSyntaxCheckerTest.java
Thu Dec 21 10:17:33 2006
@@ -0,0 +1,70 @@
+/*
+ *  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.shared.ldap.schema.syntax;
+
+import junit.framework.TestCase;
+
+/**
+ * Test cases for DSETypeSyntaxChecker.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class DSETypeSyntaxCheckerTest extends TestCase
+{
+    DSETypeSyntaxChecker checker = new DSETypeSyntaxChecker();
+
+
+    public void testNullString()
+    {
+        assertFalse( checker.isValidSyntax( null ) );
+    }
+
+
+    public void testEmptyString()
+    {
+        assertFalse( checker.isValidSyntax( "" ) );
+    }
+
+
+    public void testWrongCase()
+    {
+        assertFalse( checker.isValidSyntax( "()" ) );
+        assertFalse( checker.isValidSyntax( "(xyz)" ) );
+        assertFalse( checker.isValidSyntax( "sa" ) );
+        assertFalse( checker.isValidSyntax( "(SA)" ) );
+        assertFalse( checker.isValidSyntax( " () " ) );
+        assertFalse( checker.isValidSyntax( " (sa) " ) );
+        assertFalse( checker.isValidSyntax( "(sa) " ) );
+        assertFalse( checker.isValidSyntax( "(sa$)" ) );
+        assertFalse( checker.isValidSyntax( "(sa$ )" ) );
+        assertFalse( checker.isValidSyntax( "( sa $ sa )" ) );
+    }
+    
+    
+    public void testCorrectCase()
+    {
+        assertTrue( checker.isValidSyntax( "(sa)" ) );
+        assertTrue( checker.isValidSyntax( "(  sa   )" ) );
+        assertTrue( checker.isValidSyntax( "( root $ glue $ cp $ entry $ alias $ subr $ "
+
+                                            "nssr $ supr $ xr $ admPoint $ subentry $ " +
+                                            "shadow $ zombie $ immSupr $ rhob $ sa )" ) );
+    }
+}

Added: directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/DataQualitySyntaxSyntaxCheckerTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/DataQualitySyntaxSyntaxCheckerTest.java?view=auto&rev=489427
==============================================================================
--- directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/DataQualitySyntaxSyntaxCheckerTest.java
(added)
+++ directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/DataQualitySyntaxSyntaxCheckerTest.java
Thu Dec 21 10:17:33 2006
@@ -0,0 +1,56 @@
+/*
+ *  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.shared.ldap.schema.syntax;
+
+import junit.framework.TestCase;
+
+/**
+ * Test cases for DataQualitySyntaxSyntaxChecker.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class DataQualitySyntaxSyntaxCheckerTest extends TestCase
+{
+    DataQualitySyntaxSyntaxChecker checker = new DataQualitySyntaxSyntaxChecker();
+
+
+    public void testNullString()
+    {
+        assertTrue( checker.isValidSyntax( null ) );
+    }
+
+
+    public void testEmptyString()
+    {
+        assertTrue( checker.isValidSyntax( "" ) );
+    }
+
+    public void testOid()
+    {
+        assertEquals( "1.3.6.1.4.1.1466.115.121.1.13", checker.getSyntaxOid() );
+    }
+
+    public void testCorrectCase()
+    {
+        assertTrue( checker.isValidSyntax( "FALSE" ) );
+        assertTrue( checker.isValidSyntax( new byte[]{0x01, (byte)0xFF} ) );
+    }
+}



Mime
View raw message