@Test public void testValidateDirContextAssertions() throws Exception { final DefaultDirContextValidator dirContextValidator = new DefaultDirContextValidator(); try { dirContextValidator.validateDirContext(DirContextType.READ_ONLY, null); fail("IllegalArgumentException expected"); } catch (IllegalArgumentException expected) { assertThat(true).isTrue(); } try { dirContextValidator.validateDirContext(null, dirContextMock); fail("IllegalArgumentException expected"); } catch (IllegalArgumentException expected) { assertThat(true).isTrue(); } }
public boolean validateDirContext(DirContextType contextType, DirContext dirContext) { Assert.notNull(contextType, "contextType may not be null"); Assert.notNull(dirContext, "dirContext may not be null"); try { final NamingEnumeration<SearchResult> searchResults = dirContext.search(this.base, this.filter, this.searchControls); if (searchResults.hasMore()) { this.logger.debug("DirContext '{}' passed validation.", dirContext); return true; } } catch (Exception e) { this.logger.debug("DirContext '{}' failed validation with an exception.", dirContext, e); return false; } this.logger.debug("DirContext '{}' failed validation.", dirContext); return false; }
DefaultDirContextValidator implements DirContextValidator { public boolean validateDirContext(DirContextType contextType, DirContext dirContext) { Assert.notNull(contextType, "contextType may not be null"); Assert.notNull(dirContext, "dirContext may not be null"); try { final NamingEnumeration<SearchResult> searchResults = dirContext.search(this.base, this.filter, this.searchControls); if (searchResults.hasMore()) { this.logger.debug("DirContext '{}' passed validation.", dirContext); return true; } } catch (Exception e) { this.logger.debug("DirContext '{}' failed validation with an exception.", dirContext, e); return false; } this.logger.debug("DirContext '{}' failed validation.", dirContext); return false; } }
DefaultDirContextValidator implements DirContextValidator { public boolean validateDirContext(DirContextType contextType, DirContext dirContext) { Assert.notNull(contextType, "contextType may not be null"); Assert.notNull(dirContext, "dirContext may not be null"); try { final NamingEnumeration<SearchResult> searchResults = dirContext.search(this.base, this.filter, this.searchControls); if (searchResults.hasMore()) { this.logger.debug("DirContext '{}' passed validation.", dirContext); return true; } } catch (Exception e) { this.logger.debug("DirContext '{}' failed validation with an exception.", dirContext, e); return false; } this.logger.debug("DirContext '{}' failed validation.", dirContext); return false; } DefaultDirContextValidator();  DefaultDirContextValidator(int searchScope); }
DefaultDirContextValidator implements DirContextValidator { public boolean validateDirContext(DirContextType contextType, DirContext dirContext) { Assert.notNull(contextType, "contextType may not be null"); Assert.notNull(dirContext, "dirContext may not be null"); try { final NamingEnumeration<SearchResult> searchResults = dirContext.search(this.base, this.filter, this.searchControls); if (searchResults.hasMore()) { this.logger.debug("DirContext '{}' passed validation.", dirContext); return true; } } catch (Exception e) { this.logger.debug("DirContext '{}' failed validation with an exception.", dirContext, e); return false; } this.logger.debug("DirContext '{}' failed validation.", dirContext); return false; } DefaultDirContextValidator();  DefaultDirContextValidator(int searchScope); String getBase(); void setBase(String base); String getFilter(); void setFilter(String filter); SearchControls getSearchControls(); void setSearchControls(SearchControls searchControls); boolean validateDirContext(DirContextType contextType, DirContext dirContext); }
DefaultDirContextValidator implements DirContextValidator { public boolean validateDirContext(DirContextType contextType, DirContext dirContext) { Assert.notNull(contextType, "contextType may not be null"); Assert.notNull(dirContext, "dirContext may not be null"); try { final NamingEnumeration<SearchResult> searchResults = dirContext.search(this.base, this.filter, this.searchControls); if (searchResults.hasMore()) { this.logger.debug("DirContext '{}' passed validation.", dirContext); return true; } } catch (Exception e) { this.logger.debug("DirContext '{}' failed validation with an exception.", dirContext, e); return false; } this.logger.debug("DirContext '{}' failed validation.", dirContext); return false; } DefaultDirContextValidator();  DefaultDirContextValidator(int searchScope); String getBase(); void setBase(String base); String getFilter(); void setFilter(String filter); SearchControls getSearchControls(); void setSearchControls(SearchControls searchControls); boolean validateDirContext(DirContextType contextType, DirContext dirContext); static final String DEFAULT_FILTER; }