本文整理汇总了Java中org.apache.directory.api.ldap.model.message.AddRequest.getControls方法的典型用法代码示例。如果您正苦于以下问题:Java AddRequest.getControls方法的具体用法?Java AddRequest.getControls怎么用?Java AddRequest.getControls使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.directory.api.ldap.model.message.AddRequest
的用法示例。
在下文中一共展示了AddRequest.getControls方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testRequestWith1Control
import org.apache.directory.api.ldap.model.message.AddRequest; //导入方法依赖的package包/类
/**
* Test parsing of a request with a (optional) Control element
*/
@Test
public void testRequestWith1Control()
{
Dsmlv2Parser parser = null;
try
{
parser = newParser();
parser.setInput( AddRequestTest.class.getResource( "request_with_1_control.xml" ).openStream(), "UTF-8" );
parser.parse();
}
catch ( Exception e )
{
fail( e.getMessage() );
}
AddRequest addRequest = ( AddRequest ) parser.getBatchRequest().getCurrentRequest();
Map<String, Control> controls = addRequest.getControls();
assertEquals( 1, addRequest.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() ) );
}
示例2: testRequestWith1ControlBase64Value
import org.apache.directory.api.ldap.model.message.AddRequest; //导入方法依赖的package包/类
/**
* Test parsing of a request with a (optional) Control element with Base64 value
*/
@Test
public void testRequestWith1ControlBase64Value()
{
Dsmlv2Parser parser = null;
try
{
parser = newParser();
parser.setInput(
AddRequestTest.class.getResource( "request_with_1_control_base64_value.xml" ).openStream(), "UTF-8" );
parser.parse();
}
catch ( Exception e )
{
fail( e.getMessage() );
}
AddRequest addRequest = ( AddRequest ) parser.getBatchRequest().getCurrentRequest();
Map<String, Control> controls = addRequest.getControls();
assertEquals( 1, addRequest.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( "DSMLv2.0 rocks!!", Strings.utf8ToString( ( ( DsmlControl<?> ) control ).getValue() ) );
}
示例3: testRequestWith1ControlEmptyValue
import org.apache.directory.api.ldap.model.message.AddRequest; //导入方法依赖的package包/类
/**
* Test parsing of a request with a (optional) Control element with empty value
*/
@Test
public void testRequestWith1ControlEmptyValue()
{
Dsmlv2Parser parser = null;
try
{
parser = newParser();
parser.setInput( AddRequestTest.class.getResource( "request_with_1_control_empty_value.xml" ).openStream(),
"UTF-8" );
parser.parse();
}
catch ( Exception e )
{
fail( e.getMessage() );
}
AddRequest addRequest = ( AddRequest ) parser.getBatchRequest().getCurrentRequest();
Map<String, Control> controls = addRequest.getControls();
assertEquals( 1, addRequest.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() );
}
示例4: testRequestWith2Controls
import org.apache.directory.api.ldap.model.message.AddRequest; //导入方法依赖的package包/类
/**
* Test parsing of a request with 2 (optional) Control elements
*/
@Test
public void testRequestWith2Controls()
{
Dsmlv2Parser parser = null;
try
{
parser = newParser();
parser.setInput( AddRequestTest.class.getResource( "request_with_2_controls.xml" ).openStream(), "UTF-8" );
parser.parse();
}
catch ( Exception e )
{
fail( e.getMessage() );
}
AddRequest addRequest = ( AddRequest ) parser.getBatchRequest().getCurrentRequest();
Map<String, Control> controls = addRequest.getControls();
assertEquals( 2, addRequest.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() ) );
}
示例5: testRequestWith3ControlsWithoutValue
import org.apache.directory.api.ldap.model.message.AddRequest; //导入方法依赖的package包/类
/**
* Test parsing of a request with 3 (optional) Control elements without value
*/
@Test
public void testRequestWith3ControlsWithoutValue()
{
Dsmlv2Parser parser = null;
try
{
parser = newParser();
parser.setInput( AddRequestTest.class.getResource( "request_with_3_controls_without_value.xml" )
.openStream(), "UTF-8" );
parser.parse();
}
catch ( Exception e )
{
fail( e.getMessage() );
}
AddRequest addRequest = ( AddRequest ) parser.getBatchRequest().getCurrentRequest();
Map<String, Control> controls = addRequest.getControls();
assertEquals( 3, addRequest.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() );
}