directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1790736 - in /directory/shared/branches/shared-value/ldap: model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/ model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/ schema/data/src/test/java/or...
Date Sun, 09 Apr 2017 00:55:49 GMT
Author: elecharny
Date: Sun Apr  9 00:55:49 2017
New Revision: 1790736

URL: http://svn.apache.org/viewvc?rev=1790736&view=rev
Log:
Ported Stefa fixes to the branch

Added:
    directory/shared/branches/shared-value/ldap/schema/data/src/test/java/org/apache/directory/api/ldap/schema/manager/
    directory/shared/branches/shared-value/ldap/schema/data/src/test/java/org/apache/directory/api/ldap/schema/manager/impl/
    directory/shared/branches/shared-value/ldap/schema/data/src/test/java/org/apache/directory/api/ldap/schema/manager/impl/DefaultSchemaManagerTest.java
Modified:
    directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/FacsimileTelephoneNumberSyntaxChecker.java
    directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/TelephoneNumberSyntaxChecker.java
    directory/shared/branches/shared-value/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/FacsimileTelephoneNumberSyntaxCheckerTest.java
    directory/shared/branches/shared-value/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/TelephoneNumberSyntaxCheckerTest.java

Modified: directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/FacsimileTelephoneNumberSyntaxChecker.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/FacsimileTelephoneNumberSyntaxChecker.java?rev=1790736&r1=1790735&r2=1790736&view=diff
==============================================================================
--- directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/FacsimileTelephoneNumberSyntaxChecker.java
(original)
+++ directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/FacsimileTelephoneNumberSyntaxChecker.java
Sun Apr  9 00:55:49 2017
@@ -112,6 +112,7 @@ public final class FacsimileTelephoneNum
         private Builder()
         {
             super( SchemaConstants.FACSIMILE_TELEPHONE_NUMBER_SYNTAX );
+            setDefaultRegexp( DEFAULT_REGEXP );
         }
         
         

Modified: directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/TelephoneNumberSyntaxChecker.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/TelephoneNumberSyntaxChecker.java?rev=1790736&r1=1790735&r2=1790736&view=diff
==============================================================================
--- directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/TelephoneNumberSyntaxChecker.java
(original)
+++ directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/TelephoneNumberSyntaxChecker.java
Sun Apr  9 00:55:49 2017
@@ -50,11 +50,11 @@ public final class TelephoneNumberSyntax
     /** The default pattern used to check a TelephoneNumber */
     private static final String DEFAULT_REGEXP = "^ *[+]? *((\\([0-9- ,;/#*]+\\))|[0-9- ,;/#*]+)+$";
     
-    /** The compiled default pattern */
-    private String defaultRegexp;
+    /** The default pattern */
+    private final String defaultRegexp;
 
     /** The compiled default pattern */
-    private Pattern defaultPattern = Pattern.compile( DEFAULT_REGEXP );
+    private final Pattern defaultPattern;
 
     /**
      * A static instance of TelephoneNumberSyntaxChecker
@@ -70,7 +70,7 @@ public final class TelephoneNumberSyntax
         /** The compiled default pattern */
         private String defaultRegexp;
 
-        /** The compiled default pattern */
+        /** The default pattern */
         private Pattern defaultPattern;
 
         /**
@@ -79,6 +79,7 @@ public final class TelephoneNumberSyntax
         private Builder()
         {
             super( SchemaConstants.TELEPHONE_NUMBER_SYNTAX );
+            setDefaultRegexp( DEFAULT_REGEXP );
         }
         
         
@@ -124,7 +125,7 @@ public final class TelephoneNumberSyntax
      */
     private TelephoneNumberSyntaxChecker( String oid )
     {
-        super( oid );
+        this( oid, DEFAULT_REGEXP, Pattern.compile( DEFAULT_REGEXP ) );
     }
 
     
@@ -160,14 +161,7 @@ public final class TelephoneNumberSyntax
      */
     public String getRegexp()
     {
-        if ( defaultRegexp == null )
-        {
-            return DEFAULT_REGEXP;
-        }
-        else
-        {
-            return defaultRegexp;
-        }
+        return defaultRegexp;
     }
 
 

Modified: directory/shared/branches/shared-value/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/FacsimileTelephoneNumberSyntaxCheckerTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-value/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/FacsimileTelephoneNumberSyntaxCheckerTest.java?rev=1790736&r1=1790735&r2=1790736&view=diff
==============================================================================
--- directory/shared/branches/shared-value/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/FacsimileTelephoneNumberSyntaxCheckerTest.java
(original)
+++ directory/shared/branches/shared-value/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/FacsimileTelephoneNumberSyntaxCheckerTest.java
Sun Apr  9 00:55:49 2017
@@ -99,6 +99,14 @@ public class FacsimileTelephoneNumberSyn
         assertTrue( checker.isValidSyntax( " 01/02/03/04/05 " ) );
         assertFalse( checker.isValidSyntax( " 01 / 02 .03 04--  05 " ) );
     }
+    
+    
+    @Test
+    public void testBuilderSetsDefaultPattern()
+    {
+        checker = FacsimileTelephoneNumberSyntaxChecker.builder().build();
+        assertTrue( checker.isValidSyntax( "1" ) );
+    }
 
 
     @Test

Modified: directory/shared/branches/shared-value/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/TelephoneNumberSyntaxCheckerTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-value/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/TelephoneNumberSyntaxCheckerTest.java?rev=1790736&r1=1790735&r2=1790736&view=diff
==============================================================================
--- directory/shared/branches/shared-value/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/TelephoneNumberSyntaxCheckerTest.java
(original)
+++ directory/shared/branches/shared-value/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxes/TelephoneNumberSyntaxCheckerTest.java
Sun Apr  9 00:55:49 2017
@@ -107,4 +107,12 @@ public class TelephoneNumberSyntaxChecke
         assertTrue( checker.isValidSyntax( " 01/02/03/04/05 " ) );
         assertFalse( checker.isValidSyntax( " 01 / 02 .03 04--  05 " ) );
     }
+
+
+    @Test
+    public void testBuilderSetsDefaultPattern()
+    {
+        checker = TelephoneNumberSyntaxChecker.builder().build();
+        assertTrue( checker.isValidSyntax( "1" ) );
+    }
 }

Added: directory/shared/branches/shared-value/ldap/schema/data/src/test/java/org/apache/directory/api/ldap/schema/manager/impl/DefaultSchemaManagerTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-value/ldap/schema/data/src/test/java/org/apache/directory/api/ldap/schema/manager/impl/DefaultSchemaManagerTest.java?rev=1790736&view=auto
==============================================================================
--- directory/shared/branches/shared-value/ldap/schema/data/src/test/java/org/apache/directory/api/ldap/schema/manager/impl/DefaultSchemaManagerTest.java
(added)
+++ directory/shared/branches/shared-value/ldap/schema/data/src/test/java/org/apache/directory/api/ldap/schema/manager/impl/DefaultSchemaManagerTest.java
Sun Apr  9 00:55:49 2017
@@ -0,0 +1,49 @@
+/*
+ *  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.api.ldap.schema.manager.impl;
+
+
+import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
+import org.junit.Test;
+
+
+/**
+ * Tests the DefaultSchemaManager.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class DefaultSchemaManagerTest
+{
+    /**
+     * Verifies that all syntax checkers are properly initialized 
+     * when loading the default schema.
+     */
+    @Test
+    public void testSyntaxCheckersDoNotThrowException() throws Exception
+    {
+        DefaultSchemaManager schemaManager = new DefaultSchemaManager();
+        schemaManager.loadAllEnabled();
+
+        for ( SyntaxChecker sc : schemaManager.getSyntaxCheckerRegistry() )
+        {
+            sc.isValidSyntax( "foo" );
+        }
+    }
+}



Mime
View raw message