directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r1091706 - in /directory/apacheds/trunk/server-integ: ./ src/test/java/org/apache/directory/dsml/ src/test/java/org/apache/directory/dsml/engine/ src/test/resources/
Date Wed, 13 Apr 2011 08:48:30 GMT
Author: kayyagari
Date: Wed Apr 13 08:48:30 2011
New Revision: 1091706

URL: http://svn.apache.org/viewvc?rev=1091706&view=rev
Log:
o added a test to for DSML engine to demonstrate an NPE raised in SearchRequestDecorator while
processing a DSML search request
o added a dependency on dsml-engine and added the required test resource

Added:
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/dsml/
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/dsml/engine/
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/dsml/engine/Dsmlv2EngineTest.java
    directory/apacheds/trunk/server-integ/src/test/resources/dsml-search-req.xml
Modified:
    directory/apacheds/trunk/server-integ/pom.xml

Modified: directory/apacheds/trunk/server-integ/pom.xml
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/pom.xml?rev=1091706&r1=1091705&r2=1091706&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/pom.xml (original)
+++ directory/apacheds/trunk/server-integ/pom.xml Wed Apr 13 08:48:30 2011
@@ -154,6 +154,12 @@
       <groupId>org.apache.directory.shared</groupId>
       <artifactId>shared-ldap-client-api</artifactId>
     </dependency>  
+
+    <dependency>
+      <groupId>org.apache.directory.shared</groupId>
+      <artifactId>shared-dsml-engine</artifactId>
+      <version>${org.apache.directory.shared.version}</version>
+    </dependency>
   </dependencies>
 
   <build>

Added: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/dsml/engine/Dsmlv2EngineTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/dsml/engine/Dsmlv2EngineTest.java?rev=1091706&view=auto
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/dsml/engine/Dsmlv2EngineTest.java
(added)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/dsml/engine/Dsmlv2EngineTest.java
Wed Apr 13 08:48:30 2011
@@ -0,0 +1,107 @@
+/*
+ *   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.dsml.engine;
+
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+
+import org.apache.directory.ldap.client.api.LdapConnection;
+import org.apache.directory.ldap.client.api.LdapNetworkConnection;
+import org.apache.directory.server.annotations.CreateLdapServer;
+import org.apache.directory.server.annotations.CreateTransport;
+import org.apache.directory.server.core.annotations.CreateDS;
+import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
+import org.apache.directory.server.core.integ.FrameworkRunner;
+import org.apache.directory.shared.dsmlv2.Dsmlv2ResponseParser;
+import org.apache.directory.shared.dsmlv2.engine.Dsmlv2Engine;
+import org.apache.directory.shared.dsmlv2.reponse.BatchResponseDsml;
+import org.apache.directory.shared.dsmlv2.reponse.SearchResponse;
+import org.apache.directory.shared.ldap.codec.api.LdapCodecServiceFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+
+/**
+ * Test for demonstrating the NPE generated while processing a search DSML request by Dsmlv2Engine.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+@RunWith(FrameworkRunner.class)
+@CreateDS(name = "Dsmlv2EngineTest-DS")
+@CreateLdapServer(transports =
+    { @CreateTransport(protocol = "LDAP") })
+public class Dsmlv2EngineTest extends AbstractLdapTestUnit
+{
+    private LdapConnection connection;
+
+    private Dsmlv2Engine engine;
+
+
+    @Before
+    public void setup()
+    {
+        connection = new LdapNetworkConnection( "localhost", ldapServer.getPort() );
+        engine = new Dsmlv2Engine( connection, "uid=admin,ou=system", "secret" );
+    }
+
+
+    @After
+    public void unbind() throws Exception
+    {
+        connection.unBind();
+        connection.close();
+    }
+
+
+    //Enable WARN level logging to see the stacktrace
+    // e.x log4j.rootCategory=WARN, stdout
+    @Ignore("Failes with an NPE at org.apache.directory.shared.ldap.codec.decorators.SearchRequestDecorator.computeLength(SearchRequestDecorator.java:939)")
+    @Test
+    public void testEngineWithDefaultBlockingResponse() throws Exception
+    {
+        InputStream dsmlIn = getClass().getClassLoader().getResourceAsStream( "dsml-search-req.xml"
);
+
+        ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
+
+        engine.processDSML( dsmlIn, byteOut );
+
+        Dsmlv2ResponseParser respParser = new Dsmlv2ResponseParser( LdapCodecServiceFactory.getSingleton()
);
+        System.out.println( byteOut.toString() );
+        respParser.setInput( byteOut.toString() );
+
+        respParser.parseAllResponses();
+
+        BatchResponseDsml batchResp = respParser.getBatchResponse();
+
+        assertNotNull( batchResp );
+
+        SearchResponse searchResp = ( SearchResponse ) batchResp.getCurrentResponse().getDecorated();
+
+        assertEquals( 5, searchResp.getSearchResultEntryList().size() );
+    }
+}

Added: directory/apacheds/trunk/server-integ/src/test/resources/dsml-search-req.xml
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/resources/dsml-search-req.xml?rev=1091706&view=auto
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/resources/dsml-search-req.xml (added)
+++ directory/apacheds/trunk/server-integ/src/test/resources/dsml-search-req.xml Wed Apr 13
08:48:30 2011
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
+	<soap-env:Body>
+		<dsml:batchRequest xmlns:dsml="urn:oasis:names:tc:DSML:2:0:core"
+			xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+			<searchRequest dn="ou=system" scope="singleLevel"
+				derefAliases="neverDerefAliases" typesOnly="false" >
+				<filter>
+					<present name="objectClass">
+					</present>
+				</filter>
+				<attributes>
+				  <attribute name="*"/>
+				</attributes>
+			</searchRequest>
+		</dsml:batchRequest>
+	</soap-env:Body>
+</soap-env:Envelope>
\ No newline at end of file



Mime
View raw message