You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2010/05/26 02:44:50 UTC
svn commit: r948280 - in /directory/shared/trunk/ldap/src:
main/java/org/apache/directory/shared/ldap/filter/SimpleNode.java
test/java/org/apache/directory/shared/ldap/filter/FilterToStringTest.java
Author: elecharny
Date: Wed May 26 00:44:49 2010
New Revision: 948280
URL: http://svn.apache.org/viewvc?rev=948280&view=rev
Log:
o Added two tests for the toString() method
o Minor refactoring
Added:
directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/filter/FilterToStringTest.java
Modified:
directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/SimpleNode.java
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/SimpleNode.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/SimpleNode.java?rev=948280&r1=948279&r2=948280&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/SimpleNode.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/SimpleNode.java Wed May 26 00:44:49 2010
@@ -39,7 +39,7 @@ public abstract class SimpleNode<T> exte
/* TODO - why are these here if not used? */
/** Constants for comparisons : > */
public static final boolean EVAL_GREATER = true;
-
+
/* TODO - why are these here if not used? */
/** Constants for comparisons : < */
public static final boolean EVAL_LESSER = false;
@@ -58,17 +58,18 @@ public abstract class SimpleNode<T> exte
this.value = value;
}
-
+
/**
* Makes a full clone in new memory space of the current node and children
*/
- @Override public ExprNode clone()
+ @Override
+ public ExprNode clone()
{
ExprNode clone = super.clone();
-
+
// Clone the value
- ((SimpleNode<T>)clone).value = value.clone();
-
+ ( ( SimpleNode<T> ) clone ).value = value.clone();
+
return clone;
}
@@ -83,12 +84,13 @@ public abstract class SimpleNode<T> exte
return value;
}
+
/**
* @return representation of value, escaped for use in a filter if required
*/
public Value<?> getEscapedValue()
{
- return AbstractExprNode.escapeFilterValue( value );
+ return escapeFilterValue( value );
}
@@ -171,7 +173,7 @@ public abstract class SimpleNode<T> exte
return true;
}
- if ( !( other instanceof SimpleNode ) )
+ if ( !( other instanceof SimpleNode<?> ) )
{
return false;
}
Added: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/filter/FilterToStringTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/filter/FilterToStringTest.java?rev=948280&view=auto
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/filter/FilterToStringTest.java (added)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/filter/FilterToStringTest.java Wed May 26 00:44:49 2010
@@ -0,0 +1,54 @@
+/*
+ * 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.filter;
+
+
+import static org.junit.Assert.assertEquals;
+
+import java.text.ParseException;
+
+import org.junit.Test;
+
+
+/**
+ * Test the Filter.toString() method
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class FilterToStringTest
+{
+ @Test
+ public void testSimpleToString() throws ParseException
+ {
+ String str = "(ou=test)";
+ ExprNode node = FilterParser.parse( str );
+ assertEquals( str, node.toString() );
+ }
+
+
+ @Test
+ public void testToStringWithEscaped() throws ParseException
+ {
+ String str = "(cn=jims group\\28not bob\\29)";
+ ExprNode node = FilterParser.parse( str );
+ assertEquals( str, node.toString() );
+ }
+}