directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r1085920 - in /directory/shared/trunk/dsml/parser/src/test: java/org/apache/directory/shared/dsmlv2/soap/ resources/org/apache/directory/shared/dsmlv2/soap/
Date Sun, 27 Mar 2011 12:19:39 GMT
Author: kayyagari
Date: Sun Mar 27 12:19:39 2011
New Revision: 1085920

URL: http://svn.apache.org/viewvc?rev=1085920&view=rev
Log:
o test case and required resource files for testing the parsing of DSML document present inside
a SOAP envelope

Added:
    directory/shared/trunk/dsml/parser/src/test/java/org/apache/directory/shared/dsmlv2/soap/
    directory/shared/trunk/dsml/parser/src/test/java/org/apache/directory/shared/dsmlv2/soap/SoapDsmlParsingTest.java
    directory/shared/trunk/dsml/parser/src/test/resources/org/apache/directory/shared/dsmlv2/soap/
    directory/shared/trunk/dsml/parser/src/test/resources/org/apache/directory/shared/dsmlv2/soap/soap-dsml-multiple-operation-requests.xml
    directory/shared/trunk/dsml/parser/src/test/resources/org/apache/directory/shared/dsmlv2/soap/soap-dsml-req-with-header.xml
    directory/shared/trunk/dsml/parser/src/test/resources/org/apache/directory/shared/dsmlv2/soap/soap-dsml-req-without-header.xml

Added: directory/shared/trunk/dsml/parser/src/test/java/org/apache/directory/shared/dsmlv2/soap/SoapDsmlParsingTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml/parser/src/test/java/org/apache/directory/shared/dsmlv2/soap/SoapDsmlParsingTest.java?rev=1085920&view=auto
==============================================================================
--- directory/shared/trunk/dsml/parser/src/test/java/org/apache/directory/shared/dsmlv2/soap/SoapDsmlParsingTest.java
(added)
+++ directory/shared/trunk/dsml/parser/src/test/java/org/apache/directory/shared/dsmlv2/soap/SoapDsmlParsingTest.java
Sun Mar 27 12:19:39 2011
@@ -0,0 +1,134 @@
+/*
+ *  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.dsmlv2.soap;
+
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.apache.directory.shared.dsmlv2.Dsmlv2Parser;
+import org.apache.directory.shared.dsmlv2.request.BatchRequestDsml;
+import org.apache.directory.shared.ldap.model.message.SearchRequest;
+import org.junit.Test;
+
+
+/**
+ * Class which tests the parsing of DSML documents embedded in a SOAP envelope.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class SoapDsmlParsingTest
+{
+
+    @Test
+    public void testParsingRequestsOneByOne() throws Exception
+    {
+
+        Dsmlv2Parser parser = new Dsmlv2Parser( false );
+
+        parser.setInput( SoapDsmlParsingTest.class.getResource( "soap-dsml-multiple-operation-requests.xml"
)
+            .openStream(),
+            "UTF-8" );
+
+        parser.parseBatchRequest();
+
+        BatchRequestDsml batchReq = parser.getBatchRequest();
+
+        assertNotNull( batchReq );
+        assertFalse( batchReq.isStoringRequests() );
+
+        assertTrue( batchReq.getRequests().isEmpty() );
+
+        SearchRequest searchRequest = ( SearchRequest ) parser.getNextRequest();
+
+        assertTrue( searchRequest.getTypesOnly() );
+
+        // assert again that the batch request object is not storing requests
+        assertTrue( batchReq.getRequests().isEmpty() );
+
+        searchRequest = ( SearchRequest ) parser.getNextRequest();
+
+        assertFalse( searchRequest.getTypesOnly() );
+
+        assertNull( parser.getNextRequest() );
+
+        // assert again that the batch request object is not storing requests
+        assertTrue( batchReq.getRequests().isEmpty() );
+
+        assertNotNull( batchReq.getCurrentRequest() );
+    }
+
+
+    /**
+     * Test parsing of a request without a SOAP header
+     */
+    @Test
+    public void testBatchRequestWithoutSoapHeader()
+    {
+        Dsmlv2Parser parser = null;
+        try
+        {
+            parser = new Dsmlv2Parser();
+
+            parser.setInput( SoapDsmlParsingTest.class.getResource( "soap-dsml-req-without-header.xml"
).openStream(),
+                "UTF-8" );
+
+            SearchRequest searchRequest = ( SearchRequest ) parser.getNextRequest();
+
+            assertTrue( searchRequest.getTypesOnly() );
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+
+    }
+
+
+    /**
+     * Test parsing of a request *with* a SOAP header
+     */
+    @Test
+    public void testBatchRequestWithSoapHeader()
+    {
+        Dsmlv2Parser parser = null;
+        try
+        {
+            parser = new Dsmlv2Parser();
+
+            parser.setInput( SoapDsmlParsingTest.class.getResource( "soap-dsml-req-with-header.xml"
).openStream(),
+                "UTF-8" );
+
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+
+        SearchRequest searchRequest = ( SearchRequest ) parser.getBatchRequest().getCurrentRequest();
+
+        assertTrue( searchRequest.getTypesOnly() );
+    }
+
+}

Added: directory/shared/trunk/dsml/parser/src/test/resources/org/apache/directory/shared/dsmlv2/soap/soap-dsml-multiple-operation-requests.xml
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml/parser/src/test/resources/org/apache/directory/shared/dsmlv2/soap/soap-dsml-multiple-operation-requests.xml?rev=1085920&view=auto
==============================================================================
--- directory/shared/trunk/dsml/parser/src/test/resources/org/apache/directory/shared/dsmlv2/soap/soap-dsml-multiple-operation-requests.xml
(added)
+++ directory/shared/trunk/dsml/parser/src/test/resources/org/apache/directory/shared/dsmlv2/soap/soap-dsml-multiple-operation-requests.xml
Sun Mar 27 12:19:39 2011
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<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="uid=admin,ou=system" scope="baseObject"
+				derefAliases="neverDerefAliases" typesOnly="true">
+				<filter>
+					<approxMatch name="uid">
+						<value>admin</value>
+					</approxMatch>
+				</filter>
+			</searchRequest>
+
+			<searchRequest dn="ou=schema" scope="baseObject"
+				derefAliases="neverDerefAliases" typesOnly="false">
+				<filter>
+					<approxMatch name="cn">
+						<value>inetOrgPerson</value>
+					</approxMatch>
+				</filter>
+			</searchRequest>
+		</dsml:batchRequest>
+	</soap-env:Body>
+</soap-env:Envelope>
\ No newline at end of file

Added: directory/shared/trunk/dsml/parser/src/test/resources/org/apache/directory/shared/dsmlv2/soap/soap-dsml-req-with-header.xml
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml/parser/src/test/resources/org/apache/directory/shared/dsmlv2/soap/soap-dsml-req-with-header.xml?rev=1085920&view=auto
==============================================================================
--- directory/shared/trunk/dsml/parser/src/test/resources/org/apache/directory/shared/dsmlv2/soap/soap-dsml-req-with-header.xml
(added)
+++ directory/shared/trunk/dsml/parser/src/test/resources/org/apache/directory/shared/dsmlv2/soap/soap-dsml-req-with-header.xml
Sun Mar 27 12:19:39 2011
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
+	<soap-env:header>
+		<t:Transaction xmlns:t="http://example.org/2001/06/tx"
+			soap-env:mustUnderstand="true">
+			5 
+	    </t:Transaction>
+	    <t:header xmlns:t="http://example.org/2001/06/tx">
+	    </t:header>
+	</soap-env:header>
+	<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="uid=admin,ou=system" scope="baseObject"
+				derefAliases="neverDerefAliases" typesOnly="true">
+				<filter>
+					<approxMatch name="uid">
+						<value>admin</value>
+					</approxMatch>
+				</filter>
+			</searchRequest>
+		</dsml:batchRequest>
+	</soap-env:Body>
+</soap-env:Envelope>
\ No newline at end of file

Added: directory/shared/trunk/dsml/parser/src/test/resources/org/apache/directory/shared/dsmlv2/soap/soap-dsml-req-without-header.xml
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml/parser/src/test/resources/org/apache/directory/shared/dsmlv2/soap/soap-dsml-req-without-header.xml?rev=1085920&view=auto
==============================================================================
--- directory/shared/trunk/dsml/parser/src/test/resources/org/apache/directory/shared/dsmlv2/soap/soap-dsml-req-without-header.xml
(added)
+++ directory/shared/trunk/dsml/parser/src/test/resources/org/apache/directory/shared/dsmlv2/soap/soap-dsml-req-without-header.xml
Sun Mar 27 12:19:39 2011
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<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="uid=admin,ou=system" scope="baseObject"
+				derefAliases="neverDerefAliases" typesOnly="true">
+				<filter>
+					<approxMatch name="uid">
+						<value>admin</value>
+					</approxMatch>
+				</filter>
+			</searchRequest>
+		</dsml:batchRequest>
+	</soap-env:Body>
+</soap-env:Envelope>
\ No newline at end of file



Mime
View raw message