本文整理汇总了Java中org.apache.directory.api.ldap.model.ldif.LdifAttributesReader类的典型用法代码示例。如果您正苦于以下问题:Java LdifAttributesReader类的具体用法?Java LdifAttributesReader怎么用?Java LdifAttributesReader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LdifAttributesReader类属于org.apache.directory.api.ldap.model.ldif包,在下文中一共展示了LdifAttributesReader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testLdifComments
import org.apache.directory.api.ldap.model.ldif.LdifAttributesReader; //导入依赖的package包/类
@Test
public void testLdifComments() throws LdapLdifException, IOException
{
String ldif =
"#Comment 1\r"
+ "#\r"
+ " th\n"
+ " is is still a comment\n"
+ "\n";
LdifAttributesReader reader = new LdifAttributesReader();
Entry entry = reader.parseEntry( ldif );
assertNull( entry );
reader.close();
}
示例2: testLdifVersionStart
import org.apache.directory.api.ldap.model.ldif.LdifAttributesReader; //导入依赖的package包/类
@Test
public void testLdifVersionStart() throws LdapLdifException, IOException
{
String ldif =
"cn: app1\n"
+ "objectClass: top\n"
+ "objectClass: apApplication\n"
+ "displayName: app1 \n"
+ "dependencies:\n"
+ "envVars:";
LdifAttributesReader reader = new LdifAttributesReader();
Entry entry = reader.parseEntry( ldif );
assertEquals( 1, reader.getVersion() );
assertNotNull( entry );
Attribute attr = entry.get( "displayname" );
assertTrue( attr.contains( "app1" ) );
reader.close();
}
示例3: testLdifParserEndSpaces
import org.apache.directory.api.ldap.model.ldif.LdifAttributesReader; //导入依赖的package包/类
/**
* Spaces at the end of values should not be included into values.
*
* @throws NamingException
*/
@Test
public void testLdifParserEndSpaces() throws LdapLdifException, IOException
{
String ldif =
"cn: app1\n"
+ "objectClass: top\n"
+ "objectClass: apApplication\n"
+ "displayName: app1 \n"
+ "dependencies:\n"
+ "envVars:";
LdifAttributesReader reader = new LdifAttributesReader();
Entry entry = reader.parseEntry( ldif );
assertNotNull( entry );
Attribute attr = entry.get( "displayname" );
assertTrue( attr.contains( "app1" ) );
reader.close();
}
示例4: testLdifNull
import org.apache.directory.api.ldap.model.ldif.LdifAttributesReader; //导入依赖的package包/类
@Test
public void testLdifNull() throws LdapLdifException, IOException
{
String ldif = null;
LdifAttributesReader reader = new LdifAttributesReader();
Entry entry = reader.parseEntry( ldif );
assertEquals( 0, entry.size() );
reader.close();
}
示例5: testLdifEmpty
import org.apache.directory.api.ldap.model.ldif.LdifAttributesReader; //导入依赖的package包/类
@Test
public void testLdifEmpty() throws LdapLdifException, IOException
{
String ldif = "";
LdifAttributesReader reader = new LdifAttributesReader();
Entry entry = reader.parseEntry( ldif );
assertEquals( 0, entry.size() );
reader.close();
}
示例6: testLdifEmptyLines
import org.apache.directory.api.ldap.model.ldif.LdifAttributesReader; //导入依赖的package包/类
@Test
public void testLdifEmptyLines() throws LdapLdifException, IOException
{
String ldif = "\n\n\r\r\n";
LdifAttributesReader reader = new LdifAttributesReader();
Entry entry = reader.parseEntry( ldif );
assertNull( entry );
reader.close();
}
示例7: testLdifParser
import org.apache.directory.api.ldap.model.ldif.LdifAttributesReader; //导入依赖的package包/类
@Test
public void testLdifParser() throws LdapLdifException, LdapInvalidAttributeValueException, IOException
{
String ldif =
"cn: app1\n"
+ "objectClass: top\n"
+ "objectClass: apApplication\n"
+ "displayName: app1 \n"
+ "dependencies:\n"
+ "envVars:";
LdifAttributesReader reader = new LdifAttributesReader();
Entry entry = reader.parseEntry( ldif );
assertNotNull( entry );
Attribute attr = entry.get( "cn" );
assertTrue( attr.contains( "app1" ) );
attr = entry.get( "objectclass" );
assertTrue( attr.contains( "top" ) );
assertTrue( attr.contains( "apApplication" ) );
attr = entry.get( "displayname" );
assertTrue( attr.contains( "app1" ) );
attr = entry.get( "dependencies" );
assertEquals( "", attr.get().getValue() );
attr = entry.get( "envvars" );
assertEquals( "", attr.get().getValue() );
reader.close();
}
示例8: testLdifParserMuiltiLineComments
import org.apache.directory.api.ldap.model.ldif.LdifAttributesReader; //导入依赖的package包/类
@Test
public void testLdifParserMuiltiLineComments() throws LdapLdifException, IOException
{
String ldif =
"#comment\n"
+ " still a comment\n"
+ "cn: app1#another comment\n"
+ "objectClass: top\n"
+ "objectClass: apApplication\n"
+ "displayName: app1\n"
+ "serviceType: http\n"
+ "dependencies:\n"
+ "httpHeaders:\n"
+ "startupOptions:\n"
+ "envVars:";
LdifAttributesReader reader = new LdifAttributesReader();
Entry entry = reader.parseEntry( ldif );
assertNotNull( entry );
Attribute attr = entry.get( "cn" );
assertTrue( attr.contains( "app1#another comment" ) );
attr = entry.get( "objectclass" );
assertTrue( attr.contains( "top" ) );
assertTrue( attr.contains( "apApplication" ) );
attr = entry.get( "displayname" );
assertTrue( attr.contains( "app1" ) );
attr = entry.get( "dependencies" );
assertEquals( "", attr.get().getValue() );
attr = entry.get( "envvars" );
assertEquals( "", attr.get().getValue() );
reader.close();
}
示例9: testLdifParserMultiLineEntries
import org.apache.directory.api.ldap.model.ldif.LdifAttributesReader; //导入依赖的package包/类
@Test
public void testLdifParserMultiLineEntries() throws LdapLdifException, IOException
{
String ldif =
"#comment\n"
+ "cn: app1#another comment\n"
+ "objectClass: top\n"
+ "objectClass: apAppli\n"
+ " cation\n"
+ "displayName: app1\n"
+ "serviceType: http\n"
+ "dependencies:\n"
+ "httpHeaders:\n"
+ "startupOptions:\n"
+ "envVars:";
LdifAttributesReader reader = new LdifAttributesReader();
Entry entry = reader.parseEntry( ldif );
assertNotNull( entry );
Attribute attr = entry.get( "cn" );
assertTrue( attr.contains( "app1#another comment" ) );
attr = entry.get( "objectclass" );
assertTrue( attr.contains( "top" ) );
assertTrue( attr.contains( "apApplication" ) );
attr = entry.get( "displayname" );
assertTrue( attr.contains( "app1" ) );
attr = entry.get( "dependencies" );
assertEquals( "", attr.get().getValue() );
attr = entry.get( "envvars" );
assertEquals( "", attr.get().getValue() );
reader.close();
}
示例10: testLdifParserBase64
import org.apache.directory.api.ldap.model.ldif.LdifAttributesReader; //导入依赖的package包/类
@Test
public void testLdifParserBase64() throws LdapLdifException, IOException
{
String ldif =
"#comment\n"
+ "cn:: RW1tYW51ZWwgTMOpY2hhcm55\n"
+ "objectClass: top\n"
+ "objectClass: apApplication\n"
+ "displayName: app1\n"
+ "serviceType: http\n"
+ "dependencies:\n"
+ "httpHeaders:\n"
+ "startupOptions:\n"
+ "envVars:";
LdifAttributesReader reader = new LdifAttributesReader();
Entry entry = reader.parseEntry( ldif );
assertNotNull( entry );
Attribute attr = entry.get( "cn" );
assertTrue( attr.contains( "Emmanuel L\u00e9charny".getBytes( StandardCharsets.UTF_8 ) ) );
attr = entry.get( "objectclass" );
assertTrue( attr.contains( "top" ) );
assertTrue( attr.contains( "apApplication" ) );
attr = entry.get( "displayname" );
assertTrue( attr.contains( "app1" ) );
attr = entry.get( "dependencies" );
assertEquals( "", attr.get().getValue() );
attr = entry.get( "envvars" );
assertEquals( "", attr.get().getValue() );
reader.close();
}
示例11: testLdifParserBase64MultiLine
import org.apache.directory.api.ldap.model.ldif.LdifAttributesReader; //导入依赖的package包/类
@Test
public void testLdifParserBase64MultiLine() throws LdapLdifException, IOException
{
String ldif =
"#comment\n"
+ "cn:: RW1tYW51ZWwg\n"
+ " TMOpY2hhcm55ICA=\n"
+ "objectClass: top\n"
+ "objectClass: apApplication\n"
+ "displayName: app1\n"
+ "serviceType: http\n"
+ "dependencies:\n"
+ "httpHeaders:\n"
+ "startupOptions:\n"
+ "envVars:";
LdifAttributesReader reader = new LdifAttributesReader();
Entry entry = reader.parseEntry( ldif );
assertNotNull( entry );
Attribute attr = entry.get( "cn" );
assertTrue( attr.contains( "Emmanuel L\u00e9charny ".getBytes( StandardCharsets.UTF_8 ) ) );
attr = entry.get( "objectclass" );
assertTrue( attr.contains( "top" ) );
assertTrue( attr.contains( "apApplication" ) );
attr = entry.get( "displayname" );
assertTrue( attr.contains( "app1" ) );
attr = entry.get( "dependencies" );
assertEquals( "", attr.get().getValue() );
attr = entry.get( "envvars" );
assertEquals( "", attr.get().getValue() );
reader.close();
}
示例12: testLdifParserRFC2849Sample5WithSizeLimit
import org.apache.directory.api.ldap.model.ldif.LdifAttributesReader; //导入依赖的package包/类
@Test
public void testLdifParserRFC2849Sample5WithSizeLimit() throws Exception
{
String ldif =
"objectclass: top\n"
+ "objectclass: person\n"
+ "objectclass: organizationalPerson\n"
+ "cn: Horatio Jensen\n"
+ "cn: Horatio N Jensen\n"
+ "sn: Jensen\n"
+ "uid: hjensen\n"
+ "telephonenumber: +1 408 555 1212\n"
+ "jpegphoto:< file:"
+ HJENSEN_JPEG_FILE.getAbsolutePath()
+ "\n";
LdifAttributesReader reader = new LdifAttributesReader();
reader.setSizeLimit( 128 );
try
{
reader.parseEntry( ldif );
fail();
}
catch ( LdapLdifException ne )
{
assertTrue( I18n.err( I18n.ERR_12009_ERROR_PARSING_LDIF_BUFFER ), ne.getMessage().startsWith(
I18n.ERR_12009_ERROR_PARSING_LDIF_BUFFER.getErrorCode() ) );
}
reader.close();
}
示例13: createEntry
import org.apache.directory.api.ldap.model.ldif.LdifAttributesReader; //导入依赖的package包/类
private Entry createEntry( SchemaManager schemaManager, Object... elements )
throws LdapInvalidAttributeValueException, LdapLdifException
{
StringBuilder sb = new StringBuilder();
int pos = 0;
boolean valueExpected = false;
for ( Object element : elements )
{
if ( !valueExpected )
{
if ( !( element instanceof String ) )
{
throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err(
I18n.ERR_12085, pos + 1 ) );
}
String attribute = ( String ) element;
sb.append( attribute );
if ( attribute.indexOf( ':' ) != -1 )
{
sb.append( '\n' );
}
else
{
valueExpected = true;
}
}
else
{
if ( element instanceof String )
{
sb.append( ": " ).append( ( String ) element ).append( '\n' );
}
else if ( element instanceof byte[] )
{
sb.append( ":: " );
sb.append( new String( Base64.encode( ( byte[] ) element ) ) );
sb.append( '\n' );
}
else
{
throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err(
I18n.ERR_12086, pos + 1 ) );
}
valueExpected = false;
}
}
if ( valueExpected )
{
throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n
.err( I18n.ERR_12087 ) );
}
try ( LdifAttributesReader reader = new LdifAttributesReader() )
{
return reader.parseEntry( schemaManager, sb.toString() );
}
catch ( IOException e )
{
throw new LdapLdifException( "Cannot read an entry" );
}
}
示例14: testLdifParserRFC2849Sample1
import org.apache.directory.api.ldap.model.ldif.LdifAttributesReader; //导入依赖的package包/类
@Test
public void testLdifParserRFC2849Sample1() throws LdapLdifException, IOException
{
String ldif =
"objectclass: top\n"
+ "objectclass: person\n"
+ "objectclass: organizationalPerson\n"
+ "cn: Barbara Jensen\n"
+ "cn: Barbara J Jensen\n"
+ "cn: Babs Jensen\n"
+ "sn: Jensen\n"
+ "uid: bjensen\n"
+ "telephonenumber: +1 408 555 1212\n"
+ "description: A big sailing fan.\n";
LdifAttributesReader reader = new LdifAttributesReader();
Entry entry = reader.parseEntry( ldif );
Attribute attr = entry.get( "objectclass" );
assertTrue( attr.contains( "top" ) );
assertTrue( attr.contains( "person" ) );
assertTrue( attr.contains( "organizationalPerson" ) );
attr = entry.get( "cn" );
assertTrue( attr.contains( "Barbara Jensen" ) );
assertTrue( attr.contains( "Barbara J Jensen" ) );
assertTrue( attr.contains( "Babs Jensen" ) );
attr = entry.get( "sn" );
assertTrue( attr.contains( "Jensen" ) );
attr = entry.get( "uid" );
assertTrue( attr.contains( "bjensen" ) );
attr = entry.get( "telephonenumber" );
assertTrue( attr.contains( "+1 408 555 1212" ) );
attr = entry.get( "description" );
assertTrue( attr.contains( "A big sailing fan." ) );
reader.close();
}
示例15: testLdifParserRFC2849Sample2
import org.apache.directory.api.ldap.model.ldif.LdifAttributesReader; //导入依赖的package包/类
@Test
public void testLdifParserRFC2849Sample2() throws LdapLdifException, IOException
{
String ldif =
"objectclass: top\n"
+ "objectclass: person\n"
+ "objectclass: organizationalPerson\n"
+ "cn: Barbara Jensen\n"
+ "cn: Barbara J Jensen\n"
+ "cn: Babs Jensen\n"
+ "sn: Jensen\n"
+ "uid: bjensen\n"
+ "telephonenumber: +1 408 555 1212\n"
+ "description:Babs is a big sailing fan, and travels extensively in sea\n"
+ " rch of perfect sailing conditions.\n"
+ "title:Product Manager, Rod and Reel Division";
LdifAttributesReader reader = new LdifAttributesReader();
Entry entry = reader.parseEntry( ldif );
Attribute attr = entry.get( "objectclass" );
assertTrue( attr.contains( "top" ) );
assertTrue( attr.contains( "person" ) );
assertTrue( attr.contains( "organizationalPerson" ) );
attr = entry.get( "cn" );
assertTrue( attr.contains( "Barbara Jensen" ) );
assertTrue( attr.contains( "Barbara J Jensen" ) );
assertTrue( attr.contains( "Babs Jensen" ) );
attr = entry.get( "sn" );
assertTrue( attr.contains( "Jensen" ) );
attr = entry.get( "uid" );
assertTrue( attr.contains( "bjensen" ) );
attr = entry.get( "telephonenumber" );
assertTrue( attr.contains( "+1 408 555 1212" ) );
attr = entry.get( "description" );
assertTrue( attr
.contains( "Babs is a big sailing fan, and travels extensively in search of perfect sailing conditions." ) );
attr = entry.get( "title" );
assertTrue( attr.contains( "Product Manager, Rod and Reel Division" ) );
reader.close();
}