本文整理汇总了Java中javax.naming.directory.InvalidAttributeValueException类的典型用法代码示例。如果您正苦于以下问题:Java InvalidAttributeValueException类的具体用法?Java InvalidAttributeValueException怎么用?Java InvalidAttributeValueException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InvalidAttributeValueException类属于javax.naming.directory包,在下文中一共展示了InvalidAttributeValueException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testClear
import javax.naming.directory.InvalidAttributeValueException; //导入依赖的package包/类
/**
* Test method clear()
*/
@Test
public void testClear() throws InvalidAttributeValueException, LdapException
{
Attribute attr1 = new DefaultAttribute( "test" );
assertEquals( 0, attr1.size() );
attr1.add( ( String ) null );
assertEquals( 1, attr1.size() );
assertTrue( attr1.isHumanReadable() );
attr1.clear();
assertTrue( attr1.isHumanReadable() );
assertEquals( 0, attr1.size() );
Attribute attr2 = new DefaultAttribute( "test" );
attr2.add( BYTES1, BYTES2 );
assertEquals( 2, attr2.size() );
assertFalse( attr2.isHumanReadable() );
attr2.clear();
assertFalse( attr2.isHumanReadable() );
assertEquals( 0, attr2.size() );
}
开发者ID:apache,项目名称:directory-ldap-api,代码行数:26,代码来源:AttributeTest.java
示例2: testSize
import javax.naming.directory.InvalidAttributeValueException; //导入依赖的package包/类
/**
* Test method size()
*/
@Test
public void testSize() throws InvalidAttributeValueException, LdapException
{
Attribute attr1 = new DefaultAttribute( "test" );
assertEquals( 0, attr1.size() );
attr1.add( ( String ) null );
assertEquals( 1, attr1.size() );
Attribute attr2 = new DefaultAttribute( "test" );
attr2.add( "a", "b" );
assertEquals( 2, attr2.size() );
attr2.clear();
assertEquals( 0, attr2.size() );
}
开发者ID:apache,项目名称:directory-ldap-api,代码行数:22,代码来源:AttributeTest.java
示例3: testToString
import javax.naming.directory.InvalidAttributeValueException; //导入依赖的package包/类
/**
* Test method toString()
*/
@Test
public void testToString() throws InvalidAttributeValueException, LdapException
{
Attribute attr1 = new DefaultAttribute( "test" );
assertEquals( "test: (null)", attr1.toString() );
attr1.add( "a" );
assertEquals( "test: a", attr1.toString() );
attr1.add( "b" );
assertEquals( "test: a\ntest: b", attr1.toString() );
Attribute attr2 = new DefaultAttribute( "test" );
attr2.add( BYTES1 );
assertEquals( "test: 0x61 0x62 ", attr2.toString() );
attr2.add( BYTES3 );
assertEquals( "test: 0x61 0x62 \ntest: 0x63 ", attr2.toString() );
}
开发者ID:apache,项目名称:directory-ldap-api,代码行数:25,代码来源:AttributeTest.java
示例4: get
import javax.naming.directory.InvalidAttributeValueException; //导入依赖的package包/类
public Day<Meal> get(int location, String date) throws ParseException,
InvalidAttributeValueException {
if (formatdate.parse(date) == null) {
throw new InvalidAttributeValueException("invalid dateformat (use yyyyMMdd)");
}
uri = mensaUrl + "?location=" + location + "&date=" + date;
response =
restTemplate.exchange(uri, HttpMethod.GET, new HttpEntity<Object>(headers), String.class);
if (response.hasBody()) {
Day<Meal> day = conv.getObject(response.getBody());
if (day.getDayContent().isEmpty()) {
throw new InvalidAttributeValueException("no entries found for given date");
}
day.setId(date);
return day;
}
return null;
}
开发者ID:HTWK-App,项目名称:Server-Application,代码行数:21,代码来源:MensaRepository.java
示例5: testGetBytes
import javax.naming.directory.InvalidAttributeValueException; //导入依赖的package包/类
/**
* Test method getBytes()
*/
@Test
public void testGetBytes() throws InvalidAttributeValueException, LdapException
{
Attribute attr1 = new DefaultAttribute( "test" );
attr1.add( ( byte[] ) null );
assertNull( attr1.getBytes() );
Attribute attr2 = new DefaultAttribute( "test" );
attr2.add( BYTES1, BYTES2 );
assertTrue( Arrays.equals( BYTES1, attr2.getBytes() ) );
Attribute attr3 = new DefaultAttribute( "test" );
attr3.add( "a", "b" );
try
{
attr3.getBytes();
fail();
}
catch ( LdapInvalidAttributeValueException ivae )
{
assertTrue( true );
}
}
开发者ID:apache,项目名称:directory-ldap-api,代码行数:31,代码来源:AttributeTest.java
示例6: testGetString
import javax.naming.directory.InvalidAttributeValueException; //导入依赖的package包/类
/**
* Test method getString()
*/
@Test
public void testGetString() throws InvalidAttributeValueException, LdapException
{
Attribute attr1 = new DefaultAttribute( "test" );
attr1.add( ( String ) null );
assertEquals( null, attr1.getString() );
Attribute attr2 = new DefaultAttribute( "test" );
attr2.add( "a", "b" );
assertEquals( "a", attr2.getString() );
Attribute attr3 = new DefaultAttribute( "test" );
attr3.add( BYTES1, BYTES2 );
try
{
attr3.getString();
fail();
}
catch ( LdapInvalidAttributeValueException ivae )
{
assertTrue( true );
}
}
开发者ID:apache,项目名称:directory-ldap-api,代码行数:31,代码来源:AttributeTest.java
示例7: testGet
import javax.naming.directory.InvalidAttributeValueException; //导入依赖的package包/类
/**
* Test method get()
*/
@Test
public void testGet() throws InvalidAttributeValueException, LdapException
{
Attribute attr1 = new DefaultAttribute( "test" );
attr1.add( ( String ) null );
assertEquals( NULL_STRING_VALUE, attr1.get() );
Attribute attr2 = new DefaultAttribute( "test" );
attr2.add( "a", "b", "c" );
assertEquals( "a", attr2.get().getValue() );
attr2.remove( "a" );
assertEquals( "b", attr2.get().getValue() );
attr2.remove( "b" );
assertEquals( "c", attr2.get().getValue() );
attr2.remove( "c" );
assertNull( attr2.get() );
Attribute attr3 = new DefaultAttribute( "test" );
attr3.add( BYTES1, BYTES2, BYTES3 );
assertTrue( Arrays.equals( BYTES1, attr3.get().getBytes() ) );
attr3.remove( BYTES1 );
assertTrue( Arrays.equals( BYTES2, attr3.get().getBytes() ) );
attr3.remove( BYTES2 );
assertTrue( Arrays.equals( BYTES3, attr3.get().getBytes() ) );
attr3.remove( BYTES3 );
assertNull( attr2.get() );
}
开发者ID:apache,项目名称:directory-ldap-api,代码行数:40,代码来源:AttributeTest.java
示例8: testRemoveByteArray
import javax.naming.directory.InvalidAttributeValueException; //导入依赖的package包/类
/**
* Test method remove( byte... )
*/
@Test
public void testRemoveByteArray() throws InvalidAttributeValueException, LdapException
{
Attribute attr1 = new DefaultAttribute( "test" );
assertFalse( attr1.remove( BYTES1 ) );
attr1.add( BYTES1, BYTES2, BYTES3 );
assertTrue( attr1.remove( BYTES1 ) );
assertEquals( 2, attr1.size() );
assertTrue( attr1.remove( BYTES2, BYTES3 ) );
assertEquals( 0, attr1.size() );
assertFalse( attr1.remove( BYTES4 ) );
attr1.clear();
attr1.add( BYTES1, BYTES2, BYTES3 );
assertFalse( attr1.remove( BYTES3, BYTES4 ) );
assertEquals( 2, attr1.size() );
attr1.clear();
attr1.add( BYTES1, ( byte[] ) null, BYTES2 );
assertTrue( attr1.remove( ( byte[] ) null, BYTES1 ) );
assertEquals( 1, attr1.size() );
Attribute attr2 = new DefaultAttribute( "test" );
attr2.add( "ab", "b", "c" );
assertFalse( attr2.remove( ( byte[] ) null ) );
assertTrue( attr2.remove( BYTES1, BYTES2 ) );
assertFalse( attr2.remove( BYTES4 ) );
}
开发者ID:apache,项目名称:directory-ldap-api,代码行数:38,代码来源:AttributeTest.java
示例9: testRemoveStringArray
import javax.naming.directory.InvalidAttributeValueException; //导入依赖的package包/类
/**
* Test method remove( String... )
*/
@Test
public void testRemoveStringArray() throws InvalidAttributeValueException, LdapException
{
Attribute attr1 = new DefaultAttribute( "test" );
assertFalse( attr1.remove( "a" ) );
attr1.add( "a", "b", "c" );
assertTrue( attr1.remove( "a" ) );
assertEquals( 2, attr1.size() );
assertTrue( attr1.remove( "b", "c" ) );
assertEquals( 0, attr1.size() );
assertFalse( attr1.remove( "d" ) );
attr1.clear();
attr1.add( "a", "b", "c" );
assertFalse( attr1.remove( "b", "e" ) );
assertEquals( 2, attr1.size() );
attr1.clear();
attr1.add( "a", ( String ) null, "b" );
assertTrue( attr1.remove( ( String ) null, "a" ) );
assertEquals( 1, attr1.size() );
Attribute attr2 = new DefaultAttribute( "test" );
attr2.add( BYTES1, BYTES2, BYTES3 );
assertFalse( attr2.remove( ( String ) null ) );
assertTrue( attr2.remove( "ab", "c" ) );
assertFalse( attr2.remove( "d" ) );
}
开发者ID:apache,项目名称:directory-ldap-api,代码行数:38,代码来源:AttributeTest.java
示例10: getAvatarImage
import javax.naming.directory.InvalidAttributeValueException; //导入依赖的package包/类
private byte[] getAvatarImage(LDAPResource ldap, Entry entry) throws LdapException {
if (avatarImageAttr != null && avatarImageAttr.length() > 0) {
try {
return ldap.getByteAttribute(entry, avatarImageAttr);
} catch (InvalidAttributeValueException ex) {
throw new LdapException("Invalid attribute value while looking up " + avatarImageAttr, ex);
}
}
return null;
}
开发者ID:caelum,项目名称:mamute,代码行数:11,代码来源:LDAPApi.java
示例11: getByteAttribute
import javax.naming.directory.InvalidAttributeValueException; //导入依赖的package包/类
private byte[] getByteAttribute(Entry entry, String attribute) throws LdapException, InvalidAttributeValueException {
Attribute value = entry.get(attribute);
if (value != null) {
return value.getBytes();
}
return null;
}
开发者ID:caelum,项目名称:mamute,代码行数:8,代码来源:LDAPApi.java
示例12: getMenuByLocation
import javax.naming.directory.InvalidAttributeValueException; //导入依赖的package包/类
@Cacheable("timeCache")
@RequestMapping(value = "/{location}", method = RequestMethod.GET, produces = { "application/json; charset=UTF-8" })
public @ResponseBody
Day<Meal> getMenuByLocation(@PathVariable(value = "location") int location) throws ParseException,
InvalidAttributeValueException {
if(!locations.containsKey(location)){
throw new InvalidAttributeValueException("no valid location was chosen");
}
return repo.get(location);
}
开发者ID:HTWK-App,项目名称:Server-Application,代码行数:11,代码来源:MensaController.java
示例13: getMenuByLocationAndDate
import javax.naming.directory.InvalidAttributeValueException; //导入依赖的package包/类
@Cacheable("timeCache")
@RequestMapping(value = "/{location}/{date}", method = RequestMethod.GET, produces = { "application/json; charset=UTF-8" })
public @ResponseBody
Day<Meal> getMenuByLocationAndDate(@PathVariable(value = "location") int location,
@PathVariable(value = "date") String date) throws ParseException, InvalidAttributeValueException {
if(!locations.containsKey(location)){
throw new InvalidAttributeValueException("no valid location was chosen");
}
return repo.get(location, date);
}
开发者ID:HTWK-App,项目名称:Server-Application,代码行数:11,代码来源:MensaController.java
示例14: testAddValueArray
import javax.naming.directory.InvalidAttributeValueException; //导入依赖的package包/类
/**
* Test method add(Value...)
*/
@Test
public void testAddValueArray() throws InvalidAttributeValueException, LdapException
{
Attribute attr1 = new DefaultAttribute( "test" );
int nbAdded = attr1.add( new Value( ( String ) null ) );
assertEquals( 1, nbAdded );
assertTrue( attr1.isHumanReadable() );
assertEquals( NULL_STRING_VALUE, attr1.get() );
Attribute attr2 = new DefaultAttribute( "test" );
nbAdded = attr2.add( new Value( ( byte[] ) null ) );
assertEquals( 1, nbAdded );
assertFalse( attr2.isHumanReadable() );
assertEquals( NULL_BINARY_VALUE, attr2.get() );
Attribute attr3 = new DefaultAttribute( "test" );
nbAdded = attr3.add( new Value( "a" ), new Value( "b" ) );
assertEquals( 2, nbAdded );
assertTrue( attr3.isHumanReadable() );
assertTrue( attr3.contains( "a" ) );
assertTrue( attr3.contains( "b" ) );
Attribute attr4 = new DefaultAttribute( "test" );
nbAdded = attr4.add( new Value( BYTES1 ), new Value( BYTES2 ) );
assertEquals( 2, nbAdded );
assertFalse( attr4.isHumanReadable() );
assertTrue( attr4.contains( BYTES1 ) );
assertTrue( attr4.contains( BYTES2 ) );
Attribute attr5 = new DefaultAttribute( "test" );
nbAdded = attr5.add( new Value( "c" ), new Value( BYTES1 ) );
assertEquals( 2, nbAdded );
assertTrue( attr5.isHumanReadable() );
assertTrue( attr5.contains( "ab" ) );
assertTrue( attr5.contains( "c" ) );
Attribute attr6 = new DefaultAttribute( "test" );
nbAdded = attr6.add( new Value( BYTES1 ), new Value( "c" ) );
assertEquals( 2, nbAdded );
assertFalse( attr6.isHumanReadable() );
assertTrue( attr6.contains( BYTES1 ) );
assertTrue( attr6.contains( BYTES3 ) );
Attribute attr7 = new DefaultAttribute( "test" );
nbAdded = attr7.add( new Value( ( byte[] ) null ), new Value( "c" ) );
assertEquals( 2, nbAdded );
assertFalse( attr7.isHumanReadable() );
assertTrue( attr7.contains( NULL_BINARY_VALUE ) );
assertTrue( attr7.contains( BYTES3 ) );
Attribute attr8 = new DefaultAttribute( "test" );
nbAdded = attr8.add( new Value( ( String ) null ), new Value( BYTES1 ) );
assertEquals( 2, nbAdded );
assertTrue( attr8.isHumanReadable() );
assertTrue( attr8.contains( NULL_STRING_VALUE ) );
assertTrue( attr8.contains( "ab" ) );
}
开发者ID:apache,项目名称:directory-ldap-api,代码行数:69,代码来源:AttributeTest.java
示例15: testAddByteArray
import javax.naming.directory.InvalidAttributeValueException; //导入依赖的package包/类
/**
* Test method add( byte[]... )
*/
@Test
public void testAddByteArray() throws InvalidAttributeValueException, LdapException
{
Attribute attr1 = new DefaultAttribute( "test" );
assertEquals( 0, attr1.size() );
int nbAdded = attr1.add( ( byte[] ) null );
assertEquals( 1, nbAdded );
assertFalse( attr1.isHumanReadable() );
assertTrue( Arrays.equals( NULL_BINARY_VALUE.getBytes(), attr1.getBytes() ) );
assertEquals( 1, attr1.size() );
Attribute attr2 = new DefaultAttribute( "test" );
nbAdded = attr2.add( Strings.EMPTY_BYTES );
assertEquals( 1, nbAdded );
assertFalse( attr2.isHumanReadable() );
assertTrue( Arrays.equals( Strings.EMPTY_BYTES, attr2.getBytes() ) );
assertEquals( 1, attr2.size() );
Attribute attr3 = new DefaultAttribute( "test" );
nbAdded = attr3.add( BYTES1 );
assertEquals( 1, nbAdded );
assertFalse( attr3.isHumanReadable() );
assertTrue( Arrays.equals( BYTES1, attr3.getBytes() ) );
Attribute attr4 = new DefaultAttribute( "test" );
nbAdded = attr4.add( BYTES1, BYTES2, BYTES3, BYTES4 );
assertEquals( 4, nbAdded );
assertFalse( attr4.isHumanReadable() );
assertTrue( attr4.contains( BYTES1 ) );
assertTrue( attr4.contains( BYTES2 ) );
assertTrue( attr4.contains( BYTES3 ) );
assertTrue( attr4.contains( BYTES4 ) );
Attribute attr5 = new DefaultAttribute( "test" );
nbAdded = attr5.add( BYTES1, BYTES2, ( byte[] ) null, BYTES3 );
assertEquals( 4, nbAdded );
assertFalse( attr5.isHumanReadable() );
assertTrue( attr5.contains( BYTES1 ) );
assertTrue( attr5.contains( BYTES2 ) );
assertTrue( attr5.contains( ( byte[] ) null ) );
assertTrue( attr5.contains( BYTES3 ) );
Attribute attr6 = new DefaultAttribute( "test" );
nbAdded = attr6.add( BYTES1, ( byte[] ) null );
assertEquals( 2, nbAdded );
assertFalse( attr6.isHumanReadable() );
assertTrue( attr6.contains( "ab" ) );
assertTrue( attr6.contains( ( byte[] ) null ) );
}
开发者ID:apache,项目名称:directory-ldap-api,代码行数:59,代码来源:AttributeTest.java
示例16: testContainsValueArray
import javax.naming.directory.InvalidAttributeValueException; //导入依赖的package包/类
/**
* Test method contains( Value... )
*/
@Test
public void testContainsValueArray() throws InvalidAttributeValueException, LdapException
{
Attribute attr1 = new DefaultAttribute( "test" );
assertEquals( 0, attr1.size() );
assertFalse( attr1.contains( STR_VALUE1 ) );
assertFalse( attr1.contains( NULL_STRING_VALUE ) );
attr1.add( ( String ) null );
assertEquals( 1, attr1.size() );
assertTrue( attr1.contains( NULL_STRING_VALUE ) );
attr1.remove( ( String ) null );
assertFalse( attr1.contains( NULL_STRING_VALUE ) );
assertEquals( 0, attr1.size() );
attr1.add( "a", "b", "c" );
assertEquals( 3, attr1.size() );
assertTrue( attr1.contains( STR_VALUE1 ) );
assertTrue( attr1.contains( STR_VALUE2 ) );
assertTrue( attr1.contains( STR_VALUE3 ) );
assertTrue( attr1.contains( STR_VALUE1, STR_VALUE3 ) );
assertFalse( attr1.contains( STR_VALUE4 ) );
assertFalse( attr1.contains( NULL_STRING_VALUE ) );
assertTrue( attr1.contains( STR_VALUE1, BIN_VALUE2 ) );
Attribute attr2 = new DefaultAttribute( "test" );
assertEquals( 0, attr2.size() );
assertFalse( attr2.contains( BYTES1 ) );
assertFalse( attr2.contains( NULL_BINARY_VALUE ) );
attr2.add( ( byte[] ) null );
assertEquals( 1, attr2.size() );
assertTrue( attr2.contains( NULL_BINARY_VALUE ) );
attr2.remove( ( byte[] ) null );
assertFalse( attr2.contains( NULL_BINARY_VALUE ) );
assertEquals( 0, attr2.size() );
attr2.add( BYTES1, BYTES2, BYTES3 );
assertEquals( 3, attr2.size() );
assertTrue( attr2.contains( BIN_VALUE1 ) );
assertTrue( attr2.contains( BIN_VALUE2 ) );
assertTrue( attr2.contains( BIN_VALUE3 ) );
assertFalse( attr2.contains( NULL_BINARY_VALUE ) );
assertTrue( attr2.contains( STR_VALUE2, BIN_VALUE1 ) );
}
开发者ID:apache,项目名称:directory-ldap-api,代码行数:52,代码来源:AttributeTest.java
示例17: testContainsStringArray
import javax.naming.directory.InvalidAttributeValueException; //导入依赖的package包/类
/**
* Test method contains( String... )
*/
@Test
public void testContainsStringArray() throws InvalidAttributeValueException, LdapException
{
Attribute attr1 = new DefaultAttribute( "test" );
assertEquals( 0, attr1.size() );
assertFalse( attr1.contains( "a" ) );
assertFalse( attr1.contains( ( String ) null ) );
attr1.add( ( String ) null );
assertEquals( 1, attr1.size() );
assertTrue( attr1.contains( ( String ) null ) );
attr1.remove( ( String ) null );
assertFalse( attr1.contains( ( String ) null ) );
assertEquals( 0, attr1.size() );
attr1.add( "a", "b", "c" );
assertEquals( 3, attr1.size() );
assertTrue( attr1.contains( "a" ) );
assertTrue( attr1.contains( "b" ) );
assertTrue( attr1.contains( "c" ) );
assertFalse( attr1.contains( "e" ) );
assertFalse( attr1.contains( ( String ) null ) );
Attribute attr2 = new DefaultAttribute( "test" );
assertEquals( 0, attr2.size() );
assertFalse( attr2.contains( BYTES1 ) );
assertFalse( attr2.contains( ( byte[] ) null ) );
attr2.add( ( byte[] ) null );
assertEquals( 1, attr2.size() );
assertTrue( attr2.contains( ( byte[] ) null ) );
attr2.remove( ( byte[] ) null );
assertFalse( attr2.contains( ( byte[] ) null ) );
assertEquals( 0, attr2.size() );
attr2.add( BYTES1, BYTES2, BYTES3 );
assertEquals( 3, attr2.size() );
assertTrue( attr2.contains( "ab" ) );
assertTrue( attr2.contains( "b" ) );
assertTrue( attr2.contains( "c" ) );
assertFalse( attr2.contains( ( String ) null ) );
}
开发者ID:apache,项目名称:directory-ldap-api,代码行数:49,代码来源:AttributeTest.java
示例18: testContainsByteArray
import javax.naming.directory.InvalidAttributeValueException; //导入依赖的package包/类
/**
* Test method contains( byte... )
*/
@Test
public void testContainsByteArray() throws InvalidAttributeValueException, LdapException
{
Attribute attr1 = new DefaultAttribute( "test" );
assertEquals( 0, attr1.size() );
assertFalse( attr1.contains( BYTES1 ) );
assertFalse( attr1.contains( ( byte[] ) null ) );
attr1.add( ( byte[] ) null );
assertEquals( 1, attr1.size() );
assertTrue( attr1.contains( ( byte[] ) null ) );
attr1.remove( ( byte[] ) null );
assertFalse( attr1.contains( ( byte[] ) null ) );
assertEquals( 0, attr1.size() );
attr1.add( BYTES1, BYTES2, BYTES3 );
assertEquals( 3, attr1.size() );
assertTrue( attr1.contains( BYTES1 ) );
assertTrue( attr1.contains( BYTES2 ) );
assertTrue( attr1.contains( BYTES3 ) );
assertFalse( attr1.contains( BYTES4 ) );
assertFalse( attr1.contains( ( byte[] ) null ) );
Attribute attr2 = new DefaultAttribute( "test" );
assertEquals( 0, attr2.size() );
assertFalse( attr2.contains( "a" ) );
assertFalse( attr2.contains( ( String ) null ) );
attr2.add( ( String ) null );
assertEquals( 1, attr2.size() );
assertTrue( attr2.contains( ( String ) null ) );
attr2.remove( ( String ) null );
assertFalse( attr2.contains( ( String ) null ) );
assertEquals( 0, attr2.size() );
attr2.add( "ab", "b", "c" );
assertEquals( 3, attr2.size() );
assertTrue( attr2.contains( BYTES1 ) );
assertTrue( attr2.contains( BYTES2 ) );
assertTrue( attr2.contains( BYTES3 ) );
assertFalse( attr2.contains( ( byte[] ) null ) );
}
开发者ID:apache,项目名称:directory-ldap-api,代码行数:49,代码来源:AttributeTest.java
示例19: testRemoveValueArray
import javax.naming.directory.InvalidAttributeValueException; //导入依赖的package包/类
/**
* Test method remove( Value... )
*/
@Test
public void testRemoveValueArray() throws InvalidAttributeValueException, LdapException
{
Attribute attr1 = new DefaultAttribute( "test" );
assertFalse( attr1.remove( STR_VALUE1 ) );
assertFalse( attr1.remove( STR_VALUE1 ) );
attr1.add( "a", "b", "c" );
assertTrue( attr1.remove( STR_VALUE1 ) );
assertEquals( 2, attr1.size() );
assertTrue( attr1.remove( STR_VALUE2, STR_VALUE3 ) );
assertEquals( 0, attr1.size() );
assertFalse( attr1.remove( STR_VALUE4 ) );
attr1.clear();
attr1.add( "a", "b", "c" );
assertFalse( attr1.remove( STR_VALUE2, STR_VALUE4 ) );
assertEquals( 2, attr1.size() );
attr1.clear();
attr1.add( "a", ( String ) null, "b" );
assertTrue( attr1.remove( NULL_STRING_VALUE, STR_VALUE1 ) );
assertEquals( 1, attr1.size() );
attr1.clear();
attr1.add( "a", ( String ) null, "b" );
attr1.add( BYTES3 );
assertTrue( attr1.remove( NULL_STRING_VALUE, STR_VALUE1 ) );
assertEquals( 1, attr1.size() );
Attribute attr2 = new DefaultAttribute( "test" );
assertFalse( attr2.remove( BIN_VALUE1 ) );
attr2.clear();
attr2.add( BYTES1, BYTES2, BYTES3 );
assertTrue( attr2.remove( BIN_VALUE1 ) );
assertEquals( 2, attr2.size() );
assertTrue( attr2.remove( BIN_VALUE2, BIN_VALUE3 ) );
assertEquals( 0, attr2.size() );
assertFalse( attr2.remove( BIN_VALUE4 ) );
attr2.clear();
attr2.add( BYTES1, BYTES2, BYTES3 );
assertFalse( attr2.remove( BIN_VALUE2, STR_VALUE4 ) );
assertEquals( 2, attr2.size() );
attr2.clear();
attr2.add( BYTES1, ( byte[] ) null, BYTES3 );
assertFalse( attr2.remove( NULL_STRING_VALUE, BIN_VALUE1 ) );
assertEquals( 2, attr2.size() );
attr2.clear();
attr2.add( BYTES1, ( byte[] ) null, BYTES2 );
attr2.add( "c" );
assertEquals( 4, attr2.size() );
assertFalse( attr2.remove( NULL_STRING_VALUE, BIN_VALUE1, STR_VALUE3 ) );
assertEquals( 3, attr2.size() );
}
开发者ID:apache,项目名称:directory-ldap-api,代码行数:68,代码来源:AttributeTest.java
示例20: testPutStringArray
import javax.naming.directory.InvalidAttributeValueException; //导入依赖的package包/类
/**
* Test method put( String... )
*/
@Test
public void testPutStringArray() throws InvalidAttributeValueException, LdapException
{
Attribute attr1 = new DefaultAttribute( "test" );
int nbAdded = attr1.add( ( String ) null );
assertEquals( 1, nbAdded );
assertTrue( attr1.isHumanReadable() );
assertEquals( NULL_STRING_VALUE, attr1.get() );
Attribute attr2 = new DefaultAttribute( "test" );
nbAdded = attr2.add( "" );
assertEquals( 1, nbAdded );
assertTrue( attr2.isHumanReadable() );
assertEquals( "", attr2.getString() );
Attribute attr3 = new DefaultAttribute( "test" );
nbAdded = attr3.add( "t" );
assertEquals( 1, nbAdded );
assertTrue( attr3.isHumanReadable() );
assertEquals( "t", attr3.getString() );
Attribute attr4 = new DefaultAttribute( "test" );
nbAdded = attr4.add( "a", "b", "c", "d" );
assertEquals( 4, nbAdded );
assertTrue( attr4.isHumanReadable() );
assertTrue( attr4.contains( "a" ) );
assertTrue( attr4.contains( "b" ) );
assertTrue( attr4.contains( "c" ) );
assertTrue( attr4.contains( "d" ) );
Attribute attr5 = new DefaultAttribute( "test" );
nbAdded = attr5.add( "a", "b", ( String ) null, "d" );
assertEquals( 4, nbAdded );
assertTrue( attr5.isHumanReadable() );
assertTrue( attr5.contains( "a" ) );
assertTrue( attr5.contains( "b" ) );
assertTrue( attr5.contains( ( String ) null ) );
assertTrue( attr5.contains( "d" ) );
Attribute attr6 = new DefaultAttribute( "test" );
nbAdded = attr6.add( "a", ( String ) null );
assertEquals( 2, nbAdded );
assertTrue( attr6.isHumanReadable() );
assertTrue( attr6.contains( "a" ) );
assertTrue( attr6.contains( ( String ) null ) );
}
开发者ID:apache,项目名称:directory-ldap-api,代码行数:56,代码来源:AttributeTest.java
注:本文中的javax.naming.directory.InvalidAttributeValueException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论