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 2011/02/09 16:10:53 UTC
svn commit: r1068929 [4/4] - in
/directory/shared/branches/m1/ldap-codec/src/test/java/org/apache/directory/shared/ldap/codec:
./ abandon/ add/ bind/ compare/ del/ extended/ intermediate/ modify/
modifyDn/ search/ search/controls/
Modified: directory/shared/branches/m1/ldap-codec/src/test/java/org/apache/directory/shared/ldap/codec/search/controls/PagedSearchControlTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/ldap-codec/src/test/java/org/apache/directory/shared/ldap/codec/search/controls/PagedSearchControlTest.java?rev=1068929&r1=1068928&r2=1068929&view=diff
==============================================================================
--- directory/shared/branches/m1/ldap-codec/src/test/java/org/apache/directory/shared/ldap/codec/search/controls/PagedSearchControlTest.java (original)
+++ directory/shared/branches/m1/ldap-codec/src/test/java/org/apache/directory/shared/ldap/codec/search/controls/PagedSearchControlTest.java Wed Feb 9 15:10:51 2011
@@ -6,16 +6,16 @@
* 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.
- *
+ * under the License.
+ *
*/
package org.apache.directory.shared.ldap.codec.search.controls;
@@ -27,29 +27,27 @@ import static org.junit.Assert.assertTru
import java.nio.ByteBuffer;
import java.util.Arrays;
-import com.mycila.junit.concurrent.Concurrency;
-import com.mycila.junit.concurrent.ConcurrentJunitRunner;
import org.apache.directory.shared.asn1.DecoderException;
-import org.apache.directory.shared.ldap.codec.api.DefaultLdapCodecService;
-import org.apache.directory.shared.ldap.codec.api.LdapCodecService;
+import org.apache.directory.shared.ldap.codec.AbstractCodecServiceTest;
import org.apache.directory.shared.ldap.codec.controls.search.pagedSearch.PagedResultsDecorator;
import org.apache.directory.shared.ldap.model.message.controls.PagedResults;
import org.apache.directory.shared.util.Strings;
import org.junit.Test;
import org.junit.runner.RunWith;
+import com.mycila.junit.concurrent.Concurrency;
+import com.mycila.junit.concurrent.ConcurrentJunitRunner;
+
/**
* Test the PagedSearchControlTest codec
- *
+ *
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@RunWith(ConcurrentJunitRunner.class)
@Concurrency()
-public class PagedSearchControlTest
+public class PagedSearchControlTest extends AbstractCodecServiceTest
{
- private LdapCodecService codec = new DefaultLdapCodecService();
-
/**
* Test encoding of a PagedSearchControl.
*/
@@ -58,7 +56,7 @@ public class PagedSearchControlTest
{
ByteBuffer bb = ByteBuffer.allocate( 0x0B );
bb.put( new byte[]
- {
+ {
0x30, 0x09, // realSearchControlValue ::= SEQUENCE {
0x02, 0x01, 0x20, // size INTEGER,
0x04, 0x04, 't', 'e', 's', 't' // cookie OCTET STRING,
@@ -66,13 +64,13 @@ public class PagedSearchControlTest
bb.flip();
PagedResultsDecorator decorator = new PagedResultsDecorator( codec );
-
+
PagedResults pagedSearch = (PagedResults)decorator.decode( bb.array() );
assertEquals( 32, pagedSearch.getSize() );
assertTrue( Arrays.equals( Strings.getBytesUtf8("test"),
pagedSearch.getCookie() ) );
-
+
bb.flip();
PagedResultsDecorator ctrl = new PagedResultsDecorator( codec );
@@ -84,8 +82,8 @@ public class PagedSearchControlTest
String expected = Strings.dumpBytes( bb.array() );
assertEquals( expected, decoded );
}
-
-
+
+
/**
* Test the decoding of a PagedSearchControl with no cookie
*/
@@ -94,18 +92,18 @@ public class PagedSearchControlTest
{
ByteBuffer bb = ByteBuffer.allocate( 0x05 );
bb.put( new byte[]
- {
+ {
0x30, 0x03, // realSearchControlValue ::= SEQUENCE {
0x02, 0x01, 0x20 // size INTEGER,
} );
bb.flip();
PagedResultsDecorator decorator = new PagedResultsDecorator( codec );
-
+
decorator.decode( bb.array() );
}
-
-
+
+
/**
* Test the decoding of a PagedSearchControl with no size
*/
@@ -114,18 +112,18 @@ public class PagedSearchControlTest
{
ByteBuffer bb = ByteBuffer.allocate( 0x08 );
bb.put( new byte[]
- {
+ {
0x30, 0x06, // realSearchControlValue ::= SEQUENCE {
0x04, 0x04, 't', 'e', 's', 't' // cookie OCTET STRING,
} );
bb.flip();
PagedResultsDecorator decorator = new PagedResultsDecorator( codec );
-
+
decorator.decode( bb.array() );
}
-
-
+
+
/**
* Test the decoding of a PagedSearchControl with no size and no cookie
*/
@@ -134,17 +132,17 @@ public class PagedSearchControlTest
{
ByteBuffer bb = ByteBuffer.allocate( 0x02 );
bb.put( new byte[]
- {
- 0x30, 0x00, // realSearchControlValue ::= SEQUENCE
+ {
+ 0x30, 0x00, // realSearchControlValue ::= SEQUENCE
} );
bb.flip();
PagedResultsDecorator decorator = new PagedResultsDecorator( codec );
-
+
decorator.decode( bb.array() );
}
-
-
+
+
/**
* Test encoding of a PagedSearchControl with a negative size
*/
@@ -153,7 +151,7 @@ public class PagedSearchControlTest
{
ByteBuffer bb = ByteBuffer.allocate( 0x0b );
bb.put( new byte[]
- {
+ {
0x30, 0x09, // realSearchControlValue ::= SEQUENCE {
0x02, 0x01, (byte)0xFF, // size INTEGER,
0x04, 0x04, 't', 'e', 's', 't' // cookie OCTET STRING,
@@ -161,13 +159,13 @@ public class PagedSearchControlTest
bb.flip();
PagedResultsDecorator decorator = new PagedResultsDecorator( codec );
-
+
PagedResults pagedSearch = (PagedResults)decorator.decode( bb.array() );
assertEquals( Integer.MAX_VALUE, pagedSearch.getSize() );
assertTrue( Arrays.equals( Strings.getBytesUtf8("test"),
pagedSearch.getCookie() ) );
-
+
bb.flip();
@@ -180,8 +178,8 @@ public class PagedSearchControlTest
String expected = Strings.dumpBytes( bb.array() );
assertEquals( expected, decoded );
}
-
-
+
+
/**
* Test encoding of a PagedSearchControl with a empty size
*/
@@ -190,7 +188,7 @@ public class PagedSearchControlTest
{
ByteBuffer bb = ByteBuffer.allocate( 0x0a );
bb.put( new byte[]
- {
+ {
0x30, 0x08, // realSearchControlValue ::= SEQUENCE {
0x02, 0x00, // size INTEGER,
0x04, 0x04, 't', 'e', 's', 't' // cookie OCTET STRING,
@@ -198,11 +196,11 @@ public class PagedSearchControlTest
bb.flip();
PagedResultsDecorator decorator = new PagedResultsDecorator( codec );
-
+
decorator.decode( bb.array() );
}
-
-
+
+
/**
* Test encoding of a PagedSearchControl with a empty cookie
*/
@@ -211,7 +209,7 @@ public class PagedSearchControlTest
{
ByteBuffer bb = ByteBuffer.allocate( 0x07 );
bb.put( new byte[]
- {
+ {
0x30, 0x05, // realSearchControlValue ::= SEQUENCE {
0x02, 0x01, 0x20, // size INTEGER,
0x04, 0x00 // cookie OCTET STRING,
@@ -219,12 +217,12 @@ public class PagedSearchControlTest
bb.flip();
PagedResultsDecorator decorator = new PagedResultsDecorator( codec );
-
+
PagedResults pagedSearch = (PagedResults)decorator.decode( bb.array() );
assertEquals( 32, pagedSearch.getSize() );
assertNull( pagedSearch.getCookie() );
-
+
PagedResultsDecorator ctrl = new PagedResultsDecorator( codec );
ctrl.setSize( 32 );
ctrl.setCookie( null );
Modified: directory/shared/branches/m1/ldap-codec/src/test/java/org/apache/directory/shared/ldap/codec/search/controls/SubEntryControlTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/ldap-codec/src/test/java/org/apache/directory/shared/ldap/codec/search/controls/SubEntryControlTest.java?rev=1068929&r1=1068928&r2=1068929&view=diff
==============================================================================
--- directory/shared/branches/m1/ldap-codec/src/test/java/org/apache/directory/shared/ldap/codec/search/controls/SubEntryControlTest.java (original)
+++ directory/shared/branches/m1/ldap-codec/src/test/java/org/apache/directory/shared/ldap/codec/search/controls/SubEntryControlTest.java Wed Feb 9 15:10:51 2011
@@ -6,16 +6,16 @@
* 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.
- *
+ * under the License.
+ *
*/
package org.apache.directory.shared.ldap.codec.search.controls;
@@ -27,30 +27,28 @@ import static org.junit.Assert.fail;
import java.nio.ByteBuffer;
-import com.mycila.junit.concurrent.Concurrency;
-import com.mycila.junit.concurrent.ConcurrentJunitRunner;
import org.apache.directory.shared.asn1.DecoderException;
import org.apache.directory.shared.asn1.EncoderException;
-import org.apache.directory.shared.ldap.codec.api.DefaultLdapCodecService;
-import org.apache.directory.shared.ldap.codec.api.LdapCodecService;
+import org.apache.directory.shared.ldap.codec.AbstractCodecServiceTest;
import org.apache.directory.shared.ldap.codec.controls.search.subentries.SubentriesDecorator;
import org.apache.directory.shared.ldap.model.message.controls.Subentries;
import org.apache.directory.shared.util.Strings;
import org.junit.Test;
import org.junit.runner.RunWith;
+import com.mycila.junit.concurrent.Concurrency;
+import com.mycila.junit.concurrent.ConcurrentJunitRunner;
+
/**
* Test the SubEntryControlTest codec
- *
+ *
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@RunWith(ConcurrentJunitRunner.class)
@Concurrency()
-public class SubEntryControlTest
+public class SubEntryControlTest extends AbstractCodecServiceTest
{
- private LdapCodecService codec = new DefaultLdapCodecService();
-
/**
* Test the decoding of a SubEntryControl with a true visibility
*/
@@ -59,17 +57,17 @@ public class SubEntryControlTest
{
ByteBuffer bb = ByteBuffer.allocate( 0x03 );
bb.put( new byte[]
- {
+ {
0x01, 0x01, ( byte ) 0xFF // Visibility ::= BOOLEAN
} );
bb.flip();
SubentriesDecorator decorator = new SubentriesDecorator( codec );
-
+
Subentries subentries = (Subentries)decorator.decode( bb.array() );
assertTrue( subentries.isVisible() );
-
+
// test encoding
try
{
@@ -93,17 +91,17 @@ public class SubEntryControlTest
{
ByteBuffer bb = ByteBuffer.allocate( 0x03 );
bb.put( new byte[]
- {
+ {
0x01, 0x01, 0x00 // Visibility ::= BOOLEAN
} );
bb.flip();
SubentriesDecorator decorator = new SubentriesDecorator( codec );
-
+
Subentries subentries = (Subentries)decorator.decode( bb.array() );
assertFalse( subentries.isVisible() );
-
+
// test encoding
try
{
@@ -128,7 +126,7 @@ public class SubEntryControlTest
ByteBuffer bb = ByteBuffer.allocate( 0x02 );
bb.put( new byte[]
- {
+ {
0x01, 0x00 // Visibility ::= BOOLEAN
} );
@@ -136,7 +134,7 @@ public class SubEntryControlTest
// Allocate a LdapMessage Container
SubentriesDecorator decorator = new SubentriesDecorator( codec );
-
+
decorator.decode( bb.array() );
}
@@ -150,7 +148,7 @@ public class SubEntryControlTest
ByteBuffer bb = ByteBuffer.allocate( 0x03 );
bb.put( new byte[]
- {
+ {
0x02, 0x01, 0x01 // Visibility ::= BOOLEAN
} );
@@ -158,7 +156,7 @@ public class SubEntryControlTest
// Allocate a LdapMessage Container
SubentriesDecorator decorator = new SubentriesDecorator( codec );
-
+
decorator.decode( bb.array() );
}
}