directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1424372 - in /directory/shared/branches/shared-refact/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema: comparators/ normalizers/ syntaxCheckers/
Date Thu, 20 Dec 2012 09:12:49 GMT
Author: elecharny
Date: Thu Dec 20 09:12:48 2012
New Revision: 1424372

URL: http://svn.apache.org/viewvc?rev=1424372&view=rev
Log:
Added three classes used to generate bytecode for the server Schema tests

Added:
    directory/shared/branches/shared-refact/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/comparators/DummyComparator.java
  (with props)
    directory/shared/branches/shared-refact/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/normalizers/DummyNormalizer.java
  (with props)
    directory/shared/branches/shared-refact/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/
    directory/shared/branches/shared-refact/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/DummySyntaxChecker.java
  (with props)

Added: directory/shared/branches/shared-refact/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/comparators/DummyComparator.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-refact/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/comparators/DummyComparator.java?rev=1424372&view=auto
==============================================================================
--- directory/shared/branches/shared-refact/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/comparators/DummyComparator.java
(added)
+++ directory/shared/branches/shared-refact/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/comparators/DummyComparator.java
Thu Dec 20 09:12:48 2012
@@ -0,0 +1,65 @@
+/*
+ *  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.model.schema.comparators;
+
+
+import java.io.Serializable;
+
+import org.apache.directory.api.ldap.model.schema.LdapComparator;
+
+
+/**
+ * A Dummy comparator used for tests
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class DummyComparator extends LdapComparator<String> implements Serializable
+{
+    /** The serial version UID */
+    private static final long serialVersionUID = 2L;
+
+
+    /**
+     * The DummyComparator constructor. Its OID is the StringOrderingMatch matching
+     * rule OID.
+     */
+    public DummyComparator( String oid )
+    {
+        super( oid );
+    }
+
+
+    /**
+     * Compare two objects.
+     * 
+     * @param obj1 First object
+     * @param obj2 Second object
+     * @return 1 if obj1 > obj2, 0 if obj1 == obj2, -1 if obj1 < obj2
+     */
+    public int compare( String obj1, String obj2 )
+    {
+        if ( obj1 == obj2 )
+        {
+            return 0;
+        }
+
+        return obj1.compareTo( obj2 );
+    }
+}

Propchange: directory/shared/branches/shared-refact/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/comparators/DummyComparator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: directory/shared/branches/shared-refact/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/normalizers/DummyNormalizer.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-refact/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/normalizers/DummyNormalizer.java?rev=1424372&view=auto
==============================================================================
--- directory/shared/branches/shared-refact/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/normalizers/DummyNormalizer.java
(added)
+++ directory/shared/branches/shared-refact/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/normalizers/DummyNormalizer.java
Thu Dec 20 09:12:48 2012
@@ -0,0 +1,90 @@
+/*
+ *  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.model.schema.normalizers;
+
+
+import org.apache.directory.api.ldap.model.constants.SchemaConstants;
+import org.apache.directory.api.ldap.model.entry.StringValue;
+import org.apache.directory.api.ldap.model.entry.Value;
+import org.apache.directory.api.ldap.model.exception.LdapException;
+import org.apache.directory.api.ldap.model.schema.Normalizer;
+import org.apache.directory.api.util.Strings;
+
+
+/**
+ * A Dummy normalizer used for tests.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+@SuppressWarnings("serial")
+public class DummyNormalizer extends Normalizer
+{
+    /** A Dummy normalizer */
+    private static final DummyNormalizer NORMALIZER = new DummyNormalizer();
+
+
+    public DummyNormalizer()
+    {
+        super( SchemaConstants.CASE_IGNORE_MATCH_MR_OID );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public Value<?> normalize( Value<?> value ) throws LdapException
+    {
+        String str = value.getString();
+
+        if ( Strings.isEmpty( str ) )
+        {
+            return new StringValue( str );
+        }
+
+        return new StringValue( str );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String normalize( String value ) throws LdapException
+    {
+        if ( Strings.isEmpty( value ) )
+        {
+            return value;
+        }
+
+        return value;
+    }
+
+
+    /**
+     * Normalize the given String
+     *
+     * @param string The string to normalize
+     * @return The normalized object
+     * @throws LdapException If the normalization throws an error
+     */
+    public static String normalizeString( String string ) throws LdapException
+    {
+        return NORMALIZER.normalize( string );
+    }
+}

Propchange: directory/shared/branches/shared-refact/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/normalizers/DummyNormalizer.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: directory/shared/branches/shared-refact/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/DummySyntaxChecker.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-refact/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/DummySyntaxChecker.java?rev=1424372&view=auto
==============================================================================
--- directory/shared/branches/shared-refact/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/DummySyntaxChecker.java
(added)
+++ directory/shared/branches/shared-refact/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/DummySyntaxChecker.java
Thu Dec 20 09:12:48 2012
@@ -0,0 +1,63 @@
+/*
+ *  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.model.schema.syntaxCheckers;
+
+
+import org.apache.directory.api.ldap.model.constants.SchemaConstants;
+import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
+
+
+/**
+ * A Dummy SyntaxChecker used for tests
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+@SuppressWarnings("serial")
+public class DummySyntaxChecker extends SyntaxChecker
+{
+    /**
+     * Creates a new instance of DummySyntaxChecker.
+     */
+    public DummySyntaxChecker()
+    {
+        super( SchemaConstants.OCTET_STRING_SYNTAX );
+    }
+
+
+    /**
+     * Creates a new instance of DummySyntaxChecker, with a specific OID
+     * 
+     * @param oid The Syntax's OID 
+     */
+    public DummySyntaxChecker( String oid )
+    {
+        super( oid );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isValidSyntax( Object value )
+    {
+        // Always true.
+        return true;
+    }
+}

Propchange: directory/shared/branches/shared-refact/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/DummySyntaxChecker.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message