OpenLdapSchemaFileExporter { public static String toSourceCode( Schema schema ) { StringBuffer sb = new StringBuffer(); for ( AttributeType at : SchemaObjectSorter.hierarchicalOrdered( schema.getAttributeTypes() ) ) { sb.append( toSourceCode( at ) ); sb.append( "\n" ); } for ( ObjectClass oc : SchemaObjectSorter.sortObjectClasses( schema.getObjectClasses() ) ) { sb.append( toSourceCode( oc ) ); sb.append( "\n" ); } return sb.toString(); }  static String toSourceCode( Schema schema ); static String toSourceCode( AttributeType at ); static String toSourceCode( ObjectClass oc );  }
@Test public void testOpenLdapSchemaRendererObjectClassSimple() { String actual = OpenLdapSchemaFileExporter.toSourceCode( objectClassSimple ); String expected = "objectclass ( 1.2.3.4 NAME 'name0'\n\tSTRUCTURAL\n\tMUST att0 )"; assertEquals( expected, actual ); }
@Test public void testOpenLdapSchemaRendererObjectClassComplex() { String actual = OpenLdapSchemaFileExporter.toSourceCode( objectClassComplex ); String expected = "objectclass ( 1.2.3.4 NAME ( 'name1' 'name2' )\n\tDESC 'description with \\27quotes\\27'\n\tOBSOLETE\n\tSUP 1.3.5.7\n\tAUXILIARY\n\tMUST ( att1 $ att2 )\n\tMAY ( att3 $ att4 ) )"; assertEquals( expected, actual ); }
@Test public void testOpenLdapSchemaRendererAttributeTypeSimple() { String actual = OpenLdapSchemaFileExporter.toSourceCode( attributeTypeSimple ); String expected = "attributetype ( 1.2.3.4 NAME 'name0'\n\tEQUALITY matchingRule0\n\tSYNTAX 2.3.4.5{512}\n\tCOLLECTIVE\n\tUSAGE userApplications )"; assertEquals( expected, actual ); }
@Test public void testOpenLdapSchemaRendererAttributeTypeComplex() { String actual = OpenLdapSchemaFileExporter.toSourceCode( attributeTypeComplex ); String expected = "attributetype ( 1.2.3.4 NAME ( 'name1' 'name2' )\n\tDESC 'description with \\27quotes\\27'\n\tOBSOLETE\n\tSUP superAttr\n\tEQUALITY matchingRule1\n\tORDERING matchingRule2\n\tSUBSTR matchingRule3\n\tSINGLE-VALUE\n\tNO-USER-MODIFICATION\n\tUSAGE directoryOperation )"; assertEquals( expected, actual ); }