Java 8 CommunicationException - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 CommunicationException class.

This code example shows how to use the following methods:
  public void testGetGroupsWithConnectionClosed() throws IOException, NamingException {
    // The case mocks connection is closed/gc-ed, so the first search call throws CommunicationException, 
    // then after reconnected return the user NamingEnumeration first, and then the group 
    when(mockContext.search(anyString(), anyString(), any(Object[].class),
        any(SearchControls.class)))
        .thenThrow(new CommunicationException("Connection is closed"))
        .thenReturn(mockUserNamingEnum, mockGroupNamingEnum);
     
    // Although connection is down but after reconnected it still should retrieve the result groups 
    doTestGetGroups(Arrays.asList(testGroups), 1 + 2); // 1 is the first failure call 
  } 
 
  @Test
  public void testGetGroupsWithLdapDown() throws IOException, NamingException {
    // This mocks the case where Ldap server is down, and always throws CommunicationException  
    when(mockContext.search(anyString(), anyString(), any(Object[].class),
        any(SearchControls.class)))
        .thenThrow(new CommunicationException("Connection is closed"));
     
    // Ldap server is down, no groups should be retrieved 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getMessage
			throw new DimeDNSCannotResolveException( 
					"DNS failure: unable to resolve said " + said + " at "
							+ dimeDns + ": " + e.getMessage(), e);
 
		} catch (CommunicationException e) {
			throw new DimeDNSCannotConnectException( 
					"DNS failure: CommunicationException, propably server not accessible: " 
							+ dimeDns + " (for said:" + said + "): " + e.getMessage(), e);
		} catch (NamingException e) {
			throw new DimeDNSException( 
					"DNS failure when trying to retrieve said " + said
							+ " at " + dimeDns + ": " + e.getMessage(), e);
		} 
	} 
 
	public String getDimeDns() {
		return dimeDns;
	} 
 
} 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
See Code Examples for Java 8 CommunicationException Methods: