You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by se...@apache.org on 2007/04/22 16:13:19 UTC
svn commit: r531184 - in /directory/shared/trunk/ldap/src:
main/antlr/subtree-specification.g
test/java/org/apache/directory/shared/ldap/subtree/SubtreeSpecificationParserTest.java
Author: seelmann
Date: Sun Apr 22 07:13:18 2007
New Revision: 531184
URL: http://svn.apache.org/viewvc?view=rev&rev=531184
Log:
Fixed a problem when reusing the SubtreeSpecificationParser. The exclusion sets weren't cleaned
Modified:
directory/shared/trunk/ldap/src/main/antlr/subtree-specification.g
directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/subtree/SubtreeSpecificationParserTest.java
Modified: directory/shared/trunk/ldap/src/main/antlr/subtree-specification.g
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/antlr/subtree-specification.g?view=diff&rev=531184&r1=531183&r2=531184
==============================================================================
--- directory/shared/trunk/ldap/src/main/antlr/subtree-specification.g (original)
+++ directory/shared/trunk/ldap/src/main/antlr/subtree-specification.g Sun Apr 22 07:13:18 2007
@@ -84,8 +84,8 @@
private NormalizerMappingResolver resolver;
- private Set chopBeforeExclusions = new HashSet();
- private Set chopAfterExclusions = new HashSet();
+ private Set chopBeforeExclusions = null;
+ private Set chopAfterExclusions = null;
private SubtreeSpecificationModifier ssModifier = null;
@@ -153,12 +153,15 @@
subtreeSpecification returns [SubtreeSpecification ss]
{
log.debug( "entered subtreeSpecification()" );
- // clear out ss, ssModifier and subtreeSpecificationComponentsMonitor
+ // clear out ss, ssModifier, subtreeSpecificationComponentsMonitor,
+ // chopBeforeExclusions and chopAfterExclusions
// in case something is left from the last parse
ss = null;
ssModifier = new SubtreeSpecificationModifier();
subtreeSpecificationComponentsMonitor = new OptionalComponentsMonitor(
new String [] { "base", "specificExclusions", "minimum", "maximum", "specificationFilter" } );
+ chopBeforeExclusions = new HashSet();
+ chopAfterExclusions = new HashSet();
}
:
OPEN_CURLY ( SP )*
Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/subtree/SubtreeSpecificationParserTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/subtree/SubtreeSpecificationParserTest.java?view=diff&rev=531184&r1=531183&r2=531184
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/subtree/SubtreeSpecificationParserTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/subtree/SubtreeSpecificationParserTest.java Sun Apr 22 07:13:18 2007
@@ -357,6 +357,26 @@
/**
+ * Test reusability, especially if the state is resetted.
+ */
+ public void testReusabiltiy() throws Exception
+ {
+ LdapDN firstDN = new LdapDN("k=l");
+ String firstExclusion = "{ specificExclusions { chopAfter:\"k=l\" } }";
+ SubtreeSpecification firstSpec = parser.parse( firstExclusion );
+ assertEquals( 1, firstSpec.getChopAfterExclusions().size() );
+ assertEquals( firstDN, (LdapDN)firstSpec.getChopAfterExclusions().iterator().next() );
+
+ LdapDN secondDN = new LdapDN("x=y");
+ String secondExclusion = "{ specificExclusions { chopAfter:\"x=y\" } }";
+ SubtreeSpecification secondSpec = parser.parse( secondExclusion );
+ assertEquals( 1, secondSpec.getChopAfterExclusions().size() );
+ assertEquals( secondDN, (LdapDN)secondSpec.getChopAfterExclusions().iterator().next() );
+
+ }
+
+
+ /**
* Tests the multithreaded use of a single parser.
*/
public void testMultiThreaded() throws Exception