本文整理汇总了Java中javax.naming.directory.InvalidAttributeValueException类的典型用法代码示例。如果您正苦于以下问题:Java InvalidAttributeValueException类的具体用法?Java InvalidAttributeValueException怎么用?Java InvalidAttributeValueException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InvalidAttributeValueException类属于javax.naming.directory包,在下文中一共展示了InvalidAttributeValueException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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() );
}
示例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() );
}
示例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() );
}
示例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;
}
示例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 );
}
}
示例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 );
}
}
示例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() );
}
示例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 ) );
}
示例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" ) );
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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" ) );
}
示例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 ) );
}