Java Code Examples for org.apache.directory.api.ldap.model.schema.SchemaManager#lookupSyntaxCheckerRegistry()
The following examples show how to use
org.apache.directory.api.ldap.model.schema.SchemaManager#lookupSyntaxCheckerRegistry() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SchemaManagerDelTest.java From directory-ldap-api with Apache License 2.0 | 6 votes |
@Test public void testDeleteExistingSyntaxCheckerUsedBySyntax() throws Exception { SchemaManager schemaManager = loadSchema( "system" ); int scrSize = schemaManager.getSyntaxCheckerRegistry().size(); int goidSize = schemaManager.getGlobalOidRegistry().size(); SyntaxChecker sc = schemaManager.lookupSyntaxCheckerRegistry( "1.3.6.1.4.1.1466.115.121.1.1" ); //FIXME should return false but is returning true assertFalse( schemaManager.delete( sc ) ); List<Throwable> errors = schemaManager.getErrors(); assertFalse( errors.isEmpty() ); assertTrue( errors.get( 0 ) instanceof LdapProtocolErrorException ); assertEquals( scrSize, schemaManager.getSyntaxCheckerRegistry().size() ); assertEquals( goidSize, schemaManager.getGlobalOidRegistry().size() ); }
Example 2
Source File: SchemaManagerAddTest.java From directory-ldap-api with Apache License 2.0 | 6 votes |
@Test public void testAddNewSyntaxChecker() throws Exception { SchemaManager schemaManager = loadSystem(); int nrSize = schemaManager.getSyntaxCheckerRegistry().size(); int goidSize = schemaManager.getGlobalOidRegistry().size(); String oid = "0.0.0"; SyntaxChecker syntaxChecker = RegexSyntaxChecker.builder().setOid( oid ).build(); assertTrue( schemaManager.add( syntaxChecker ) ); List<Throwable> errors = schemaManager.getErrors(); assertEquals( 0, errors.size() ); assertEquals( nrSize + 1, schemaManager.getSyntaxCheckerRegistry().size() ); assertEquals( goidSize, schemaManager.getGlobalOidRegistry().size() ); SyntaxChecker added = schemaManager.lookupSyntaxCheckerRegistry( oid ); assertNotNull( added ); assertEquals( syntaxChecker.getClass().getName(), added.getFqcn() ); }
Example 3
Source File: SchemaManagerDelTest.java From directory-ldap-api with Apache License 2.0 | 5 votes |
private boolean isSyntaxCheckerPresent( SchemaManager schemaManager, String oid ) { try { SyntaxChecker syntaxChecker = schemaManager.lookupSyntaxCheckerRegistry( oid ); return syntaxChecker != null; } catch ( LdapException ne ) { return false; } }
Example 4
Source File: SchemaManagerDelTest.java From directory-ldap-api with Apache License 2.0 | 5 votes |
@Test public void testDeleteExistingSyntaxChecker() throws Exception { SchemaManager schemaManager = loadSchema( "system" ); int scrSize = schemaManager.getSyntaxCheckerRegistry().size(); int goidSize = schemaManager.getGlobalOidRegistry().size(); SyntaxChecker sc = BooleanSyntaxChecker.builder().setOid( "0.1.1" ).build(); assertTrue( schemaManager.add( sc ) ); assertEquals( scrSize + 1, schemaManager.getSyntaxCheckerRegistry().size() ); assertEquals( goidSize, schemaManager.getGlobalOidRegistry().size() ); sc = schemaManager.lookupSyntaxCheckerRegistry( "0.1.1" ); assertNotNull( sc ); assertTrue( schemaManager.delete( sc ) ); try { schemaManager.lookupSyntaxCheckerRegistry( "0.1.1" ); fail(); } catch ( Exception e ) { // expected } assertEquals( scrSize, schemaManager.getSyntaxCheckerRegistry().size() ); assertEquals( goidSize, schemaManager.getGlobalOidRegistry().size() ); }
Example 5
Source File: SchemaManagerAddTest.java From directory-ldap-api with Apache License 2.0 | 5 votes |
@Test public void testAddAlreadyExistingSyntaxChecker() throws Exception { SchemaManager schemaManager = loadSystem(); int nrSize = schemaManager.getSyntaxCheckerRegistry().size(); int goidSize = schemaManager.getGlobalOidRegistry().size(); String oid = "0.0.0"; SyntaxChecker syntaxChecker = RegexSyntaxChecker.builder().setOid( oid ).build(); assertTrue( schemaManager.add( syntaxChecker ) ); SyntaxChecker added = schemaManager.lookupSyntaxCheckerRegistry( oid ); assertNotNull( added ); assertEquals( syntaxChecker.getClass().getName(), added.getFqcn() ); List<Throwable> errors = schemaManager.getErrors(); assertEquals( 0, errors.size() ); assertEquals( nrSize + 1, schemaManager.getSyntaxCheckerRegistry().size() ); assertEquals( goidSize, schemaManager.getGlobalOidRegistry().size() ); SyntaxChecker syntaxChecker2 = RegexSyntaxChecker.builder().setOid( oid ).build(); assertFalse( schemaManager.add( syntaxChecker2 ) ); errors = schemaManager.getErrors(); assertEquals( 1, errors.size() ); assertEquals( nrSize + 1, schemaManager.getSyntaxCheckerRegistry().size() ); assertEquals( goidSize, schemaManager.getGlobalOidRegistry().size() ); added = schemaManager.lookupSyntaxCheckerRegistry( oid ); assertNotNull( added ); assertEquals( syntaxChecker.getClass().getName(), added.getFqcn() ); }
Example 6
Source File: SchemaManagerAddTest.java From directory-ldap-api with Apache License 2.0 | 5 votes |
/** * Test that we can't add two SyntaxCheckers with the same class code. */ @Test public void testAddSyntaxCheckerWithWrongFQCN() throws Exception { SchemaManager schemaManager = loadSystem(); int nrSize = schemaManager.getSyntaxCheckerRegistry().size(); int goidSize = schemaManager.getGlobalOidRegistry().size(); String oid = "0.0.0"; SyntaxChecker syntaxChecker = RegexSyntaxChecker.builder().setOid( oid ).build(); // using java.sql.ResultSet cause it is very unlikely to get loaded // in ADS, as the FQCN is not the one expected syntaxChecker.setFqcn( "java.sql.ResultSet" ); assertFalse( schemaManager.add( syntaxChecker ) ); List<Throwable> errors = schemaManager.getErrors(); errors = schemaManager.getErrors(); assertEquals( 1, errors.size() ); assertEquals( nrSize, schemaManager.getSyntaxCheckerRegistry().size() ); assertEquals( goidSize, schemaManager.getGlobalOidRegistry().size() ); try { schemaManager.lookupSyntaxCheckerRegistry( oid ); fail(); } catch ( Exception e ) { // Expected assertTrue( true ); } }
Example 7
Source File: SchemaManagerDelTest.java From directory-ldap-api with Apache License 2.0 | 4 votes |
/** * Check that a SyntaxChecker which has been used by a deleted Syntax * can be removed */ @Test public void testDeleteExistingSyntaxCheckerUsedByRemovedSyntax() throws Exception { SchemaManager schemaManager = loadSchema( "system" ); int scrSize = schemaManager.getSyntaxCheckerRegistry().size(); int srSize = schemaManager.getLdapSyntaxRegistry().size(); int goidSize = schemaManager.getGlobalOidRegistry().size(); String OID = "1.3.6.1.4.1.1466.115.121.1.33"; // Check that the S and SC are present assertTrue( isSyntaxCheckerPresent( schemaManager, OID ) ); assertTrue( isSyntaxPresent( schemaManager, OID ) ); // Now try to remove the SC SyntaxChecker sc = schemaManager.lookupSyntaxCheckerRegistry( OID ); // shouldn't be deleted cause there is a S associated with it assertFalse( schemaManager.delete( sc ) ); List<Throwable> errors = schemaManager.getErrors(); assertFalse( errors.isEmpty() ); assertTrue( errors.get( 0 ) instanceof LdapProtocolErrorException ); // Now delete the using S : it should be OK LdapSyntax syntax = new LdapSyntax( OID ); assertTrue( schemaManager.delete( syntax ) ); assertEquals( srSize - 1, schemaManager.getLdapSyntaxRegistry().size() ); assertEquals( goidSize - 1, schemaManager.getGlobalOidRegistry().size() ); assertFalse( isSyntaxPresent( schemaManager, OID ) ); // and try to delete the SC again assertTrue( schemaManager.delete( sc ) ); assertFalse( isSyntaxCheckerPresent( schemaManager, OID ) ); assertEquals( scrSize - 1, schemaManager.getSyntaxCheckerRegistry().size() ); assertEquals( goidSize - 1, schemaManager.getGlobalOidRegistry().size() ); }