本文整理汇总了Java中org.apache.directory.api.ldap.model.message.AddResponse类的典型用法代码示例。如果您正苦于以下问题:Java AddResponse类的具体用法?Java AddResponse怎么用?Java AddResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AddResponse类属于org.apache.directory.api.ldap.model.message包,在下文中一共展示了AddResponse类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testResponseWithRequestId
import org.apache.directory.api.ldap.model.message.AddResponse; //导入依赖的package包/类
/**
* Test parsing of a Response with the (optional) requestID attribute
*/
@Test
public void testResponseWithRequestId()
{
Dsmlv2ResponseParser parser = null;
try
{
parser = new Dsmlv2ResponseParser( getCodec() );
parser.setInput( AddResponseTest.class.getResource( "response_with_requestID_attribute.xml" ).openStream(),
"UTF-8" );
parser.parse();
}
catch ( Exception e )
{
fail( e.getMessage() );
}
AddResponse addResponse = ( AddResponse ) parser.getBatchResponse().getCurrentResponse();
assertEquals( 456, addResponse.getMessageId() );
}
示例2: testResponseWithResultCode
import org.apache.directory.api.ldap.model.message.AddResponse; //导入依赖的package包/类
/**
* Test parsing of a response with Result Code
*/
@Test
public void testResponseWithResultCode()
{
Dsmlv2ResponseParser parser = null;
try
{
parser = new Dsmlv2ResponseParser( getCodec() );
parser
.setInput( AddResponseTest.class.getResource( "response_with_result_code.xml" ).openStream(), "UTF-8" );
parser.parse();
}
catch ( Exception e )
{
fail( e.getMessage() );
}
AddResponse addResponse = ( AddResponse ) parser.getBatchResponse().getCurrentResponse();
LdapResult ldapResult = addResponse.getLdapResult();
assertEquals( ResultCodeEnum.PROTOCOL_ERROR, ldapResult.getResultCode() );
}
示例3: testResponseWithErrorMessage
import org.apache.directory.api.ldap.model.message.AddResponse; //导入依赖的package包/类
/**
* Test parsing of a response with Error Message
*/
@Test
public void testResponseWithErrorMessage()
{
Dsmlv2ResponseParser parser = null;
try
{
parser = new Dsmlv2ResponseParser( getCodec() );
parser.setInput( AddResponseTest.class.getResource( "response_with_error_message.xml" ).openStream(),
"UTF-8" );
parser.parse();
}
catch ( Exception e )
{
fail( e.getMessage() );
}
AddResponse addResponse = ( AddResponse ) parser.getBatchResponse().getCurrentResponse();
LdapResult ldapResult = addResponse.getLdapResult();
assertEquals( "Unrecognized extended operation EXTENSION_OID: 1.2.6.1.4.1.18060.1.1.1.100.2", ldapResult
.getDiagnosticMessage() );
}
示例4: testResponseWithEmptyErrorMessage
import org.apache.directory.api.ldap.model.message.AddResponse; //导入依赖的package包/类
/**
* Test parsing of a response with empty Error Message
*/
@Test
public void testResponseWithEmptyErrorMessage()
{
Dsmlv2ResponseParser parser = null;
try
{
parser = new Dsmlv2ResponseParser( getCodec() );
parser.setInput( AddResponseTest.class.getResource( "response_with_empty_error_message.xml" ).openStream(),
"UTF-8" );
parser.parse();
}
catch ( Exception e )
{
fail( e.getMessage() );
}
AddResponse addResponse = ( AddResponse ) parser.getBatchResponse().getCurrentResponse();
LdapResult ldapResult = addResponse.getLdapResult();
assertNull( ldapResult.getDiagnosticMessage() );
}
示例5: testResponseWithMatchedDNAttribute
import org.apache.directory.api.ldap.model.message.AddResponse; //导入依赖的package包/类
/**
* Test parsing of a response with MatchedDN attribute
*/
@Test
public void testResponseWithMatchedDNAttribute()
{
Dsmlv2ResponseParser parser = null;
try
{
parser = new Dsmlv2ResponseParser( getCodec() );
parser.setInput( AddResponseTest.class.getResource( "response_with_matchedDN_attribute.xml" ).openStream(),
"UTF-8" );
parser.parse();
}
catch ( Exception e )
{
fail( e.getMessage() );
}
AddResponse addResponse = ( AddResponse ) parser.getBatchResponse().getCurrentResponse();
LdapResult ldapResult = addResponse.getLdapResult();
assertTrue( ldapResult.getMatchedDn().equals( "cn=Bob Rush,ou=Dev,dc=Example,dc=COM" ) );
}
示例6: add
import org.apache.directory.api.ldap.model.message.AddResponse; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void add( Entry entry ) throws LdapException
{
if ( entry == null )
{
String msg = "Cannot add an empty entry";
LOG.debug( msg );
throw new IllegalArgumentException( msg );
}
AddRequest addRequest = new AddRequestImpl();
addRequest.setEntry( entry );
AddResponse addResponse = add( addRequest );
processResponse( addResponse );
}
示例7: add
import org.apache.directory.api.ldap.model.message.AddResponse; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public AddResponse add( AddRequest addRequest )
{
LdapConnection connection = null;
try
{
connection = connectionPool.getConnection();
return connection.add( addRequest );
}
catch ( LdapException e )
{
throw new LdapRuntimeException( e );
}
finally
{
returnLdapConnection( connection );
}
}
示例8: addEntry
import org.apache.directory.api.ldap.model.message.AddResponse; //导入依赖的package包/类
/**
* 添加条目
*
* Apache LDAP 主要提供三种添加条目的方法。当前用:同步的、服务器有返回响应的。
*
* @author ZhengWei(HY)
* @createDate 2017-02-14
* @version v1.0
*
* @param i_Entry
* @return 添加成功返回true。
*/
public boolean addEntry(Entry i_Entry)
{
LdapConnection v_Conn = null;
AddRequest v_AddRequest = new AddRequestImpl();
AddResponse v_Response = null;
try
{
v_AddRequest.setEntry( i_Entry);
v_AddRequest.addControl(new ManageDsaITImpl());
v_Conn = this.getConnection();
v_Response = v_Conn.add(v_AddRequest);
}
catch (Exception exce)
{
exce.printStackTrace();
}
finally
{
this.closeConnection(v_Conn);
}
return LDAP.isSuccess(v_Response);
}
示例9: testResponseWith1AddResponse
import org.apache.directory.api.ldap.model.message.AddResponse; //导入依赖的package包/类
/**
* Test parsing of a Response with the 1 AddResponse
*/
@Test
public void testResponseWith1AddResponse()
{
Dsmlv2ResponseParser parser = null;
try
{
parser = new Dsmlv2ResponseParser( getCodec() );
parser.setInput( BatchResponseTest.class.getResource( "response_with_1_AddResponse.xml" ).openStream(),
"UTF-8" );
parser.parse();
}
catch ( Exception e )
{
fail( e.getMessage() );
}
BatchResponseDsml batchResponse = parser.getBatchResponse();
assertEquals( 1, batchResponse.getResponses().size() );
DsmlDecorator<? extends Response> response = batchResponse.getCurrentResponse();
if ( response instanceof AddResponse )
{
assertTrue( true );
}
else
{
fail();
}
}
示例10: testResponseWith2AddResponse
import org.apache.directory.api.ldap.model.message.AddResponse; //导入依赖的package包/类
/**
* Test parsing of a Response with the 2 AddResponse
*/
@Test
public void testResponseWith2AddResponse()
{
Dsmlv2ResponseParser parser = null;
try
{
parser = new Dsmlv2ResponseParser( getCodec() );
parser.setInput( BatchResponseTest.class.getResource( "response_with_2_AddResponse.xml" ).openStream(),
"UTF-8" );
parser.parse();
}
catch ( Exception e )
{
fail( e.getMessage() );
}
BatchResponseDsml batchResponse = parser.getBatchResponse();
assertEquals( 2, batchResponse.getResponses().size() );
DsmlDecorator<? extends Response> response = batchResponse.getCurrentResponse();
if ( response instanceof AddResponse )
{
assertTrue( true );
}
else
{
fail();
}
}
示例11: testResponseWith1Control
import org.apache.directory.api.ldap.model.message.AddResponse; //导入依赖的package包/类
/**
* Test parsing of a response with a (optional) Control element
*/
@Test
public void testResponseWith1Control()
{
Dsmlv2ResponseParser parser = null;
try
{
parser = new Dsmlv2ResponseParser( getCodec() );
parser.setInput( AddResponseTest.class.getResource( "response_with_1_control.xml" ).openStream(), "UTF-8" );
parser.parse();
}
catch ( Exception e )
{
fail( e.getMessage() );
}
AddResponse addResponse = ( AddResponse ) parser.getBatchResponse().getCurrentResponse();
Map<String, Control> controls = addResponse.getControls();
assertEquals( 1, addResponse.getControls().size() );
Control control = controls.get( "1.2.840.113556.1.4.643" );
assertNotNull( control );
assertTrue( control.isCritical() );
assertEquals( "1.2.840.113556.1.4.643", control.getOid() );
assertEquals( "Some text", Strings.utf8ToString( ( ( DsmlControl<?> ) control ).getValue() ) );
}
示例12: testResponseWith1ControlEmptyValue
import org.apache.directory.api.ldap.model.message.AddResponse; //导入依赖的package包/类
/**
* Test parsing of a response with a (optional) Control element with emptyValue
*/
@Test
public void testResponseWith1ControlEmptyValue()
{
Dsmlv2ResponseParser parser = null;
try
{
parser = new Dsmlv2ResponseParser( getCodec() );
parser.setInput( AddResponseTest.class.getResource( "response_with_1_control_empty_value.xml" )
.openStream(), "UTF-8" );
parser.parse();
}
catch ( Exception e )
{
fail( e.getMessage() );
}
AddResponse addResponse = ( AddResponse ) parser.getBatchResponse().getCurrentResponse();
Map<String, Control> controls = addResponse.getControls();
assertEquals( 1, addResponse.getControls().size() );
Control control = controls.get( "1.2.840.113556.1.4.643" );
assertNotNull( control );
assertTrue( control.isCritical() );
assertEquals( "1.2.840.113556.1.4.643", control.getOid() );
assertFalse( ( ( DsmlControl<?> ) control ).hasValue() );
}
示例13: testResponseWith2Controls
import org.apache.directory.api.ldap.model.message.AddResponse; //导入依赖的package包/类
/**
* Test parsing of a response with 2 (optional) Control elements
*/
@Test
public void testResponseWith2Controls()
{
Dsmlv2ResponseParser parser = null;
try
{
parser = new Dsmlv2ResponseParser( getCodec() );
parser.setInput( AddResponseTest.class.getResource( "response_with_2_controls.xml" ).openStream(), "UTF-8" );
parser.parse();
}
catch ( Exception e )
{
fail( e.getMessage() );
}
AddResponse addResponse = ( AddResponse ) parser.getBatchResponse().getCurrentResponse();
Map<String, Control> controls = addResponse.getControls();
assertEquals( 2, addResponse.getControls().size() );
Control control = controls.get( "1.2.840.113556.1.4.789" );
assertNotNull( control );
assertFalse( control.isCritical() );
assertEquals( "1.2.840.113556.1.4.789", control.getOid() );
assertEquals( "Some other text", Strings.utf8ToString( ( ( DsmlControl<?> ) control ).getValue() ) );
}
示例14: testResponseWith3ControlsWithoutValue
import org.apache.directory.api.ldap.model.message.AddResponse; //导入依赖的package包/类
/**
* Test parsing of a response with 3 (optional) Control elements without value
*/
@Test
public void testResponseWith3ControlsWithoutValue()
{
Dsmlv2ResponseParser parser = null;
try
{
parser = new Dsmlv2ResponseParser( getCodec() );
parser.setInput( AddResponseTest.class.getResource( "response_with_3_controls_without_value.xml" )
.openStream(), "UTF-8" );
parser.parse();
}
catch ( Exception e )
{
fail( e.getMessage() );
}
AddResponse addResponse = ( AddResponse ) parser.getBatchResponse().getCurrentResponse();
Map<String, Control> controls = addResponse.getControls();
assertEquals( 3, addResponse.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() );
}
示例15: testResponseWith1Referral
import org.apache.directory.api.ldap.model.message.AddResponse; //导入依赖的package包/类
/**
* Test parsing of a response with a Referral
*/
@Test
public void testResponseWith1Referral()
{
Dsmlv2ResponseParser parser = null;
try
{
parser = new Dsmlv2ResponseParser( getCodec() );
parser.setInput( AddResponseTest.class.getResource( "response_with_1_referral.xml" ).openStream(), "UTF-8" );
parser.parse();
}
catch ( Exception e )
{
fail( e.getMessage() );
}
AddResponse addResponse = ( AddResponse ) parser.getBatchResponse().getCurrentResponse();
LdapResult ldapResult = addResponse.getLdapResult();
Collection<String> referrals = ldapResult.getReferral().getLdapUrls();
assertEquals( 1, referrals.size() );
assertTrue( referrals.contains( "ldap://www.apache.org/" ) );
}