use of org.apache.directory.api.dsmlv2.Dsmlv2Parser in project directory-ldap-api by apache.
the class SearchRequestTest method testRequestWithAttributes1Attribute.
/**
* Test parsing of a request with an Attributes element with 1 Attribute element
* @throws NamingException
*/
@Test
public void testRequestWithAttributes1Attribute() throws LdapException {
Dsmlv2Parser parser = null;
try {
parser = newParser();
parser.setInput(SearchRequestTest.class.getResource("request_with_attributes_1_attribute.xml").openStream(), "UTF-8");
parser.parse();
} catch (Exception e) {
fail(e.getMessage());
}
SearchRequest searchRequest = (SearchRequest) parser.getBatchRequest().getCurrentRequest();
List<String> attributes = searchRequest.getAttributes();
assertEquals(1, attributes.size());
String attribute = attributes.get(0);
assertEquals("sn", attribute);
}
use of org.apache.directory.api.dsmlv2.Dsmlv2Parser in project directory-ldap-api by apache.
the class SearchRequestTest method testRequestWith3ControlsWithoutValue.
/**
* Test parsing of a request with 3 (optional) Control elements without value
*/
@Test
public void testRequestWith3ControlsWithoutValue() {
Dsmlv2Parser parser = null;
try {
parser = newParser();
parser.setInput(SearchRequestTest.class.getResource("request_with_3_controls_without_value.xml").openStream(), "UTF-8");
parser.parse();
} catch (Exception e) {
fail(e.getMessage());
}
SearchRequest searchRequest = (SearchRequest) parser.getBatchRequest().getCurrentRequest();
Map<String, Control> controls = searchRequest.getControls();
assertEquals(3, searchRequest.getControls().size());
Control control = controls.get("1.2.840.113556.1.4.456");
assertNotNull(control);
assertTrue(control.isCritical());
assertEquals("1.2.840.113556.1.4.456", control.getOid());
assertFalse(((DsmlControl<?>) control).hasValue());
}
use of org.apache.directory.api.dsmlv2.Dsmlv2Parser in project directory-ldap-api by apache.
the class SearchRequestTest method testRequestWithRequestId.
/**
* Test parsing of a request with the (optional) requestID attribute
*/
@Test
public void testRequestWithRequestId() {
Dsmlv2Parser parser = null;
try {
parser = newParser();
parser.setInput(SearchRequestTest.class.getResource("request_with_requestID_attribute.xml").openStream(), "UTF-8");
parser.parse();
} catch (Exception e) {
fail(e.getMessage());
}
SearchRequest searchRequest = (SearchRequest) parser.getBatchRequest().getCurrentRequest();
assertEquals(456, searchRequest.getMessageId());
}
use of org.apache.directory.api.dsmlv2.Dsmlv2Parser in project directory-ldap-api by apache.
the class SoapDsmlParsingTest method testBatchRequestWithSoapHeader.
/**
* 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());
}
use of org.apache.directory.api.dsmlv2.Dsmlv2Parser in project directory-ldap-api by apache.
the class SoapDsmlParsingTest method testBatchRequestWithoutSoapHeader.
/**
* 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());
}
}
Aggregations