You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2004/04/18 07:28:08 UTC
svn commit: rev 10082 - in incubator/directory/snickers/trunk/ldap-ber-provider/src: java/org/apache/snickers/ldap test/org/apache/snickers/ldap
Author: akarasulu
Date: Sat Apr 17 22:28:08 2004
New Revision: 10082
Added:
incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/BindVersionRule.java (contents, props changed)
incubator/directory/snickers/trunk/ldap-ber-provider/src/test/org/apache/snickers/ldap/BindVersionRuleTest.java (contents, props changed)
Modified:
incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/BindNameRule.java
incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/BindSimpleCredentialsRule.java
Log:
Commit changes ...
o added completed bind version setting rule
o added unit test case for bind version setting rule
o deleted redundant default constructor definitions
Modified: incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/BindNameRule.java
==============================================================================
--- incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/BindNameRule.java (original)
+++ incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/BindNameRule.java Sat Apr 17 22:28:08 2004
@@ -32,15 +32,6 @@
public class BindNameRule extends PrimitiveOctetStringRule
{
/**
- * Creates a rule that sets the name field of a BindRequest.
- */
- public BindNameRule()
- {
- super() ;
- }
-
-
- /**
* Allows the super method to push a ByteBuffer onto the top of the stack
* which contains the drained contents of the superclass' ByteAccumulator.
* This ByteBuffer is popped first then used to populate the credentials.
Modified: incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/BindSimpleCredentialsRule.java
==============================================================================
--- incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/BindSimpleCredentialsRule.java (original)
+++ incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/BindSimpleCredentialsRule.java Sat Apr 17 22:28:08 2004
@@ -34,15 +34,6 @@
public class BindSimpleCredentialsRule extends PrimitiveOctetStringRule
{
/**
- * Creates a rule that sets the simple credentials of a BindRequest.
- */
- public BindSimpleCredentialsRule()
- {
- super() ;
- }
-
-
- /**
* Allows the super method to push a ByteBuffer onto the top of the stack
* which contains the drained contents of the superclass' ByteAccumulator.
* This ByteBuffer is popped first then used to populate the credentials.
Added: incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/BindVersionRule.java
==============================================================================
--- (empty file)
+++ incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/BindVersionRule.java Sat Apr 17 22:28:08 2004
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed 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.snickers.ldap ;
+
+
+import org.apache.ldap.common.message.BindRequest ;
+
+import org.apache.snickers.ber.digester.rules.PrimitiveIntDecodeRule ;
+
+
+/**
+ * Rule that sets the version of the BindRequest.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class BindVersionRule extends PrimitiveIntDecodeRule
+{
+ /**
+ * Super method authomatically decoded and pushs the int onto the stack
+ * which this override pops afterwords and uses to set the version on
+ * the BindRequest at the top of the object stack.
+ *
+ * @see org.apache.snickers.ber.digester.Rule#finish()
+ */
+ public void finish()
+ {
+ // pushes a int onto the primitive int stack
+ super.finish() ;
+
+ // pops the int the super method pushed
+ int version = getDigester().popInt() ;
+
+ // peek at the BindRequest underneath whose name we set
+ BindRequest req = ( BindRequest ) getDigester().peek() ;
+ req.setVersion3( version == 3 ) ;
+ }
+}
Added: incubator/directory/snickers/trunk/ldap-ber-provider/src/test/org/apache/snickers/ldap/BindVersionRuleTest.java
==============================================================================
--- (empty file)
+++ incubator/directory/snickers/trunk/ldap-ber-provider/src/test/org/apache/snickers/ldap/BindVersionRuleTest.java Sat Apr 17 22:28:08 2004
@@ -0,0 +1,100 @@
+/*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed 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.snickers.ldap ;
+
+
+import junit.framework.TestCase ;
+import org.apache.snickers.ber.digester.BERDigester;
+import org.apache.ldap.common.message.BindRequestImpl;
+import org.apache.ldap.common.message.BindRequest;
+
+import java.nio.ByteBuffer;
+
+
+/**
+ * Tests the bindVersionRule to make sure it behaves as expected.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class BindVersionRuleTest extends TestCase
+{
+ BERDigester digester ;
+ BindVersionRule bindVersionRule ;
+
+
+ /**
+ * Resets the test instances.
+ *
+ * @throws Exception on super call
+ */
+ protected void setUp() throws Exception
+ {
+ super.setUp() ;
+ digester = new BERDigester() ;
+ bindVersionRule = new BindVersionRule() ;
+ bindVersionRule.setDigester( digester ) ;
+ }
+
+
+ /**
+ * Clears (nulls out) the test instances.
+ *
+ * @throws Exception on super call
+ */
+ protected void tearDown() throws Exception
+ {
+ super.tearDown() ;
+ digester = null ;
+ bindVersionRule.setDigester( null ) ;
+ bindVersionRule = null ;
+ }
+
+
+ /**
+ * Tests the finish() method of this Rule.
+ */
+ public void testFinishVersion2()
+ {
+ digester.push( new BindRequestImpl( 77 ) ) ;
+ byte[] intBytes = new byte[1] ;
+ intBytes[0] = 2 ;
+ ByteBuffer buf = ByteBuffer.wrap( intBytes ) ;
+ bindVersionRule.length( 1 ) ;
+ bindVersionRule.value( buf ) ;
+ bindVersionRule.finish() ;
+ BindRequest req = ( BindRequest ) digester.pop() ;
+ assertFalse( req.getVersion3() ) ;
+ }
+
+
+ /**
+ * Tests the finish() method of this Rule.
+ */
+ public void testFinishVersion3()
+ {
+ digester.push( new BindRequestImpl( 77 ) ) ;
+ byte[] intBytes = new byte[1] ;
+ intBytes[0] = 3 ;
+ ByteBuffer buf = ByteBuffer.wrap( intBytes ) ;
+ bindVersionRule.length( 1 ) ;
+ bindVersionRule.value( buf ) ;
+ bindVersionRule.finish() ;
+ BindRequest req = ( BindRequest ) digester.pop() ;
+ assertTrue( req.getVersion3() ) ;
+ }
+}
\ No newline at end of file