### Question:
LdifUtils { public static Attributes createJndiAttributes( Object... avas ) throws LdapException { StringBuilder sb = new StringBuilder(); int pos = 0; boolean valueExpected = false; for ( Object ava : avas ) { if ( !valueExpected ) { if ( !( ava instanceof String ) ) { throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_13233_ATTRIBUTE_ID_MUST_BE_A_STRING, pos + 1 ) ); } String attribute = ( String ) ava; sb.append( attribute ); if ( attribute.indexOf( ':' ) != -1 ) { sb.append( '\n' ); } else { valueExpected = true; } } else { if ( ava instanceof String ) { sb.append( ": " ).append( ( String ) ava ).append( '\n' ); } else if ( ava instanceof byte[] ) { sb.append( ":: " ); sb.append( new String( Base64.encode( ( byte[] ) ava ) ) ); sb.append( '\n' ); } else { throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_13234_ATTRIBUTE_VAL_STRING_OR_BYTE, pos + 1 ) ); } valueExpected = false; } } if ( valueExpected ) { throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n .err( I18n.ERR_13234_ATTRIBUTE_VAL_STRING_OR_BYTE ) ); } try ( LdifAttributesReader reader = new LdifAttributesReader() ) { return AttributeUtils.toAttributes( reader.parseEntry( sb.toString() ) ); } catch ( IOException ioe ) { throw new LdapLdifException( ioe.getMessage(), ioe ); } } private  LdifUtils(); static boolean isLDIFSafe( String str ); static String convertToLdif( Attributes attrs ); static String convertToLdif( Attributes attrs, int length ); static String convertToLdif( Attributes attrs, Dn dn, int length ); static String convertToLdif( Attributes attrs, Dn dn ); static String convertToLdif( Entry entry ); static String convertToLdif( Entry entry, boolean includeVersionInfo ); static String convertAttributesToLdif( Entry entry ); static Attributes getJndiAttributesFromLdif( String ldif ); static String convertToLdif( Entry entry, int length ); static String convertAttributesToLdif( Entry entry, int length ); static String convertToLdif( LdifEntry entry ); static String convertToLdif( LdifEntry entry, int length ); static String convertToLdif( Attribute attr ); static String convertToLdif( Attribute attr, int length ); static String stripLineToNChars( String str, int nbChars ); static Attributes createJndiAttributes( Object... avas );  }### Answer:
@Test public void testCreateAttributesVarargs() throws LdapException, LdapLdifException, NamingException { String mOid = "m-oid: 1.2.3.4"; String description = "description"; Attributes attrs = LdifUtils.createJndiAttributes( "objectClass: top", "objectClass: metaTop", "objectClass: metaSyntax", mOid, "m-description", description ); assertEquals( "top", attrs.get( "objectClass" ).get( 0 ) ); assertEquals( "metaTop", attrs.get( "objectClass" ).get( 1 ) ); assertEquals( "metaSyntax", attrs.get( "objectClass" ).get( 2 ) ); assertEquals( "1.2.3.4", attrs.get( "m-oid" ).get() ); assertEquals( "description", attrs.get( "m-description" ).get() ); try { LdifUtils.createJndiAttributes( "objectClass", "top", "objectClass" ); fail(); } catch ( LdapInvalidAttributeValueException iave ) { assertTrue( true ); } }