类javax.naming.CommunicationException源码实例Demo

下面列出了怎么用javax.naming.CommunicationException的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: jdk8u_jdk   文件: LdapRequest.java
BerDecoder getReplyBer(long millis) throws CommunicationException,
                                           InterruptedException {
    if (cancelled) {
        throw new CommunicationException("Request: " + msgId +
            " cancelled");
    }
    if (isClosed()) {
        return null;
    }

    BerDecoder result = millis > 0 ?
            replies.poll(millis, TimeUnit.MILLISECONDS) : replies.take();

    if (cancelled) {
        throw new CommunicationException("Request: " + msgId +
            " cancelled");
    }

    return result == EOF ? null : result;
}
 
源代码2 项目: dragonwell8_jdk   文件: ResourceRecord.java
private String decodeSoa(int pos) throws CommunicationException {
    DnsName mname = new DnsName();
    pos = decodeName(pos, mname);
    DnsName rname = new DnsName();
    pos = decodeName(pos, rname);

    long serial = getUInt(pos);
    pos += 4;
    long refresh = getUInt(pos);
    pos += 4;
    long retry = getUInt(pos);
    pos += 4;
    long expire = getUInt(pos);
    pos += 4;
    long minimum = getUInt(pos);    // now used as negative TTL
    pos += 4;

    return (mname + " " + rname + " " + serial + " " +
            refresh + " " + retry + " " + expire + " " + minimum);
}
 
源代码3 项目: dragonwell8_jdk   文件: ResourceRecord.java
private String decodeNaptr(int pos) throws CommunicationException {
    int order = getUShort(pos);
    pos += 2;
    int preference = getUShort(pos);
    pos += 2;
    StringBuffer flags = new StringBuffer();
    pos += decodeCharString(pos, flags);
    StringBuffer services = new StringBuffer();
    pos += decodeCharString(pos, services);
    StringBuffer regexp = new StringBuffer(rdlen);
    pos += decodeCharString(pos, regexp);
    DnsName replacement = decodeName(pos);

    return (order + " " + preference + " " + flags + " " +
            services + " " + regexp + " " + replacement);
}
 
源代码4 项目: cxf   文件: LdapSearch.java
public Attributes getAttributes(String dn) throws NamingException {
    int retry = 0;
    while (true) {
        try {
            if (this.dirContext == null) {
                this.dirContext = createInitialContext();
            }
            return dirContext.getAttributes(dn);
        } catch (CommunicationException e) {
            LOG.log(Level.WARNING, "Error in ldap search: " + e.getMessage(), e);
            this.dirContext = null;
            retry++;
            if (retry >= numRetries) {
                throw new XKMSException(ResultMajorEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_RECEIVER,
                                        ResultMinorEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_FAILURE, "Backend failure");
            }
        }
    }
}
 
源代码5 项目: TencentKona-8   文件: ResourceRecord.java
private String decodeSoa(int pos) throws CommunicationException {
    DnsName mname = new DnsName();
    pos = decodeName(pos, mname);
    DnsName rname = new DnsName();
    pos = decodeName(pos, rname);

    long serial = getUInt(pos);
    pos += 4;
    long refresh = getUInt(pos);
    pos += 4;
    long retry = getUInt(pos);
    pos += 4;
    long expire = getUInt(pos);
    pos += 4;
    long minimum = getUInt(pos);    // now used as negative TTL
    pos += 4;

    return (mname + " " + rname + " " + serial + " " +
            refresh + " " + retry + " " + expire + " " + minimum);
}
 
源代码6 项目: TencentKona-8   文件: ResourceRecord.java
private String decodeNaptr(int pos) throws CommunicationException {
    int order = getUShort(pos);
    pos += 2;
    int preference = getUShort(pos);
    pos += 2;
    StringBuffer flags = new StringBuffer();
    pos += decodeCharString(pos, flags);
    StringBuffer services = new StringBuffer();
    pos += decodeCharString(pos, services);
    StringBuffer regexp = new StringBuffer(rdlen);
    pos += decodeCharString(pos, regexp);
    DnsName replacement = decodeName(pos);

    return (order + " " + preference + " " + flags + " " +
            services + " " + regexp + " " + replacement);
}
 
源代码7 项目: openjdk-jdk8u   文件: ResourceRecord.java
private String decodeNaptr(int pos) throws CommunicationException {
    int order = getUShort(pos);
    pos += 2;
    int preference = getUShort(pos);
    pos += 2;
    StringBuffer flags = new StringBuffer();
    pos += decodeCharString(pos, flags);
    StringBuffer services = new StringBuffer();
    pos += decodeCharString(pos, services);
    StringBuffer regexp = new StringBuffer(rdlen);
    pos += decodeCharString(pos, regexp);
    DnsName replacement = decodeName(pos);

    return (order + " " + preference + " " + flags + " " +
            services + " " + regexp + " " + replacement);
}
 
源代码8 项目: openjdk-jdk8u-backup   文件: ResourceRecord.java
private String decodeNaptr(int pos) throws CommunicationException {
    int order = getUShort(pos);
    pos += 2;
    int preference = getUShort(pos);
    pos += 2;
    StringBuffer flags = new StringBuffer();
    pos += decodeCharString(pos, flags);
    StringBuffer services = new StringBuffer();
    pos += decodeCharString(pos, services);
    StringBuffer regexp = new StringBuffer(rdlen);
    pos += decodeCharString(pos, regexp);
    DnsName replacement = decodeName(pos);

    return (order + " " + preference + " " + flags + " " +
            services + " " + regexp + " " + replacement);
}
 
源代码9 项目: openjdk-jdk9   文件: ResourceRecord.java
private String decodeNaptr(int pos) throws CommunicationException {
    int order = getUShort(pos);
    pos += 2;
    int preference = getUShort(pos);
    pos += 2;
    StringBuffer flags = new StringBuffer();
    pos += decodeCharString(pos, flags);
    StringBuffer services = new StringBuffer();
    pos += decodeCharString(pos, services);
    StringBuffer regexp = new StringBuffer(rdlen);
    pos += decodeCharString(pos, regexp);
    DnsName replacement = decodeName(pos);

    return (order + " " + preference + " " + flags + " " +
            services + " " + regexp + " " + replacement);
}
 
源代码10 项目: cxf   文件: LdapSearch.java
public NamingEnumeration<SearchResult> searchSubTree(String rootEntry, String filter) throws NamingException {
    int retry = 0;
    while (true) {
        try {
            if (this.dirContext == null) {
                this.dirContext = createInitialContext();
            }
            SearchControls ctls = new SearchControls();
            ctls.setSearchScope(SearchControls.SUBTREE_SCOPE);
            return dirContext.search(rootEntry, filter, ctls);
        } catch (CommunicationException e) {
            LOG.log(Level.WARNING, "Error in ldap search: " + e.getMessage(), e);
            this.dirContext = null;
            retry++;
            if (retry >= numRetries) {
                throw new XKMSException(ResultMajorEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_RECEIVER,
                                        ResultMinorEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_FAILURE, "Backend failure");
            }
        }
    }
}
 
源代码11 项目: dragonwell8_jdk   文件: ResourceRecord.java
private Object decodeRdata(int pos) throws CommunicationException {
    if (rrclass == CLASS_INTERNET) {
        switch (rrtype) {
        case TYPE_A:
            return decodeA(pos);
        case TYPE_AAAA:
            return decodeAAAA(pos);
        case TYPE_CNAME:
        case TYPE_NS:
        case TYPE_PTR:
            return decodeName(pos);
        case TYPE_MX:
            return decodeMx(pos);
        case TYPE_SOA:
            return decodeSoa(pos);
        case TYPE_SRV:
            return decodeSrv(pos);
        case TYPE_NAPTR:
            return decodeNaptr(pos);
        case TYPE_TXT:
            return decodeTxt(pos);
        case TYPE_HINFO:
            return decodeHinfo(pos);
        }
    }
    // Unknown RR type/class
    if (debug) {
        dprint("Unknown RR type for RR data: " + rrtype + " rdlen=" + rdlen
               + ", pos=" + pos +", msglen=" + msg.length + ", remaining="
               + (msg.length-pos));
    }
    byte[] rd = new byte[rdlen];
    System.arraycopy(msg, pos, rd, 0, rdlen);
    return rd;
}
 
源代码12 项目: dragonwell8_jdk   文件: ResourceRecord.java
private String decodeSrv(int pos) throws CommunicationException {
    int priority = getUShort(pos);
    pos += 2;
    int weight =   getUShort(pos);
    pos += 2;
    int port =     getUShort(pos);
    pos += 2;
    DnsName target = decodeName(pos);
    return (priority + " " + weight + " " + port + " " + target);
}
 
源代码13 项目: jdk8u-dev-jdk   文件: Connections.java
/**
 * Retrieves a PooledConnection from this list of connections.
 * Use an existing one if one is idle, or create one if the list's
 * max size hasn't been reached. If max size has been reached, wait
 * for a PooledConnection to be returned, or one to be removed (thus
 * not reaching the max size any longer).
 *
 * @param timeout if > 0, msec to wait until connection is available
 * @param factory creates the PooledConnection if one needs to be created
 *
 * @return A non-null PooledConnection
 * @throws NamingException PooledConnection cannot be created, because this
 * thread was interrupted while it waited for an available connection,
 * or if it timed out while waiting, or the creation of a connection
 * resulted in an error.
 */
synchronized PooledConnection get(long timeout,
    PooledConnectionFactory factory) throws NamingException {
    PooledConnection conn;
    long start = (timeout > 0 ? System.currentTimeMillis() : 0);
    long waittime = timeout;

    d("get(): before");
    while ((conn = getOrCreateConnection(factory)) == null) {
        if (timeout > 0 && waittime <= 0) {
            throw new CommunicationException(
                "Timeout exceeded while waiting for a connection: " +
                timeout + "ms");
        }
        try {
            d("get(): waiting");
            if (waittime > 0) {
                wait(waittime);  // Wait until one is released or removed
            } else {
                wait();
            }
        } catch (InterruptedException e) {
            throw new InterruptedNamingException(
                "Interrupted while waiting for a connection");
        }
        // Check whether we timed out
        if (timeout > 0) {
            long now = System.currentTimeMillis();
            waittime = timeout - (now - start);
        }
    }

    d("get(): after");
    return conn;
}
 
源代码14 项目: TencentKona-8   文件: ResourceRecord.java
ResourceRecord(byte[] msg, int msgLen, int offset,
               boolean qSection, boolean decodeRdata)
        throws CommunicationException {

    this.msg = msg;
    this.msgLen = msgLen;
    this.offset = offset;
    this.qSection = qSection;
    decode(decodeRdata);
}
 
源代码15 项目: openjdk-8   文件: Connections.java
/**
 * Retrieves a PooledConnection from this list of connections.
 * Use an existing one if one is idle, or create one if the list's
 * max size hasn't been reached. If max size has been reached, wait
 * for a PooledConnection to be returned, or one to be removed (thus
 * not reaching the max size any longer).
 *
 * @param timeout if > 0, msec to wait until connection is available
 * @param factory creates the PooledConnection if one needs to be created
 *
 * @return A non-null PooledConnection
 * @throws NamingException PooledConnection cannot be created, because this
 * thread was interrupted while it waited for an available connection,
 * or if it timed out while waiting, or the creation of a connection
 * resulted in an error.
 */
synchronized PooledConnection get(long timeout,
    PooledConnectionFactory factory) throws NamingException {
    PooledConnection conn;
    long start = (timeout > 0 ? System.currentTimeMillis() : 0);
    long waittime = timeout;

    d("get(): before");
    while ((conn = getOrCreateConnection(factory)) == null) {
        if (timeout > 0 && waittime <= 0) {
            throw new CommunicationException(
                "Timeout exceeded while waiting for a connection: " +
                timeout + "ms");
        }
        try {
            d("get(): waiting");
            if (waittime > 0) {
                wait(waittime);  // Wait until one is released or removed
            } else {
                wait();
            }
        } catch (InterruptedException e) {
            throw new InterruptedNamingException(
                "Interrupted while waiting for a connection");
        }
        // Check whether we timed out
        if (timeout > 0) {
            long now = System.currentTimeMillis();
            waittime = timeout - (now - start);
        }
    }

    d("get(): after");
    return conn;
}
 
源代码16 项目: TencentKona-8   文件: ResourceRecord.java
private String decodeSrv(int pos) throws CommunicationException {
    int priority = getUShort(pos);
    pos += 2;
    int weight =   getUShort(pos);
    pos += 2;
    int port =     getUShort(pos);
    pos += 2;
    DnsName target = decodeName(pos);
    return (priority + " " + weight + " " + port + " " + target);
}
 
源代码17 项目: TencentKona-8   文件: Connections.java
/**
 * Retrieves a PooledConnection from this list of connections.
 * Use an existing one if one is idle, or create one if the list's
 * max size hasn't been reached. If max size has been reached, wait
 * for a PooledConnection to be returned, or one to be removed (thus
 * not reaching the max size any longer).
 *
 * @param timeout if > 0, msec to wait until connection is available
 * @param factory creates the PooledConnection if one needs to be created
 *
 * @return A non-null PooledConnection
 * @throws NamingException PooledConnection cannot be created, because this
 * thread was interrupted while it waited for an available connection,
 * or if it timed out while waiting, or the creation of a connection
 * resulted in an error.
 */
synchronized PooledConnection get(long timeout,
    PooledConnectionFactory factory) throws NamingException {
    PooledConnection conn;
    long start = (timeout > 0 ? System.currentTimeMillis() : 0);
    long waittime = timeout;

    d("get(): before");
    while ((conn = getOrCreateConnection(factory)) == null) {
        if (timeout > 0 && waittime <= 0) {
            throw new CommunicationException(
                "Timeout exceeded while waiting for a connection: " +
                timeout + "ms");
        }
        try {
            d("get(): waiting");
            if (waittime > 0) {
                wait(waittime);  // Wait until one is released or removed
            } else {
                wait();
            }
        } catch (InterruptedException e) {
            throw new InterruptedNamingException(
                "Interrupted while waiting for a connection");
        }
        // Check whether we timed out
        if (timeout > 0) {
            long now = System.currentTimeMillis();
            waittime = timeout - (now - start);
        }
    }

    d("get(): after");
    return conn;
}
 
源代码18 项目: jdk8u60   文件: Connections.java
/**
 * Retrieves a PooledConnection from this list of connections.
 * Use an existing one if one is idle, or create one if the list's
 * max size hasn't been reached. If max size has been reached, wait
 * for a PooledConnection to be returned, or one to be removed (thus
 * not reaching the max size any longer).
 *
 * @param timeout if > 0, msec to wait until connection is available
 * @param factory creates the PooledConnection if one needs to be created
 *
 * @return A non-null PooledConnection
 * @throws NamingException PooledConnection cannot be created, because this
 * thread was interrupted while it waited for an available connection,
 * or if it timed out while waiting, or the creation of a connection
 * resulted in an error.
 */
synchronized PooledConnection get(long timeout,
    PooledConnectionFactory factory) throws NamingException {
    PooledConnection conn;
    long start = (timeout > 0 ? System.currentTimeMillis() : 0);
    long waittime = timeout;

    d("get(): before");
    while ((conn = getOrCreateConnection(factory)) == null) {
        if (timeout > 0 && waittime <= 0) {
            throw new CommunicationException(
                "Timeout exceeded while waiting for a connection: " +
                timeout + "ms");
        }
        try {
            d("get(): waiting");
            if (waittime > 0) {
                wait(waittime);  // Wait until one is released or removed
            } else {
                wait();
            }
        } catch (InterruptedException e) {
            throw new InterruptedNamingException(
                "Interrupted while waiting for a connection");
        }
        // Check whether we timed out
        if (timeout > 0) {
            long now = System.currentTimeMillis();
            waittime = timeout - (now - start);
        }
    }

    d("get(): after");
    return conn;
}
 
源代码19 项目: jdk8u60   文件: LdapRequest.java
synchronized BerDecoder getReplyBer() throws CommunicationException {
    if (cancelled) {
        throw new CommunicationException("Request: " + msgId +
            " cancelled");
    }

    /*
     * Remove a reply if the queue is not empty.
     * poll returns null if queue is empty.
     */
    BerDecoder reply = replies.poll();
    return reply;
}
 
源代码20 项目: openjdk-jdk8u   文件: ResourceRecord.java
ResourceRecord(byte[] msg, int msgLen, int offset,
               boolean qSection, boolean decodeRdata)
        throws CommunicationException {

    this.msg = msg;
    this.msgLen = msgLen;
    this.offset = offset;
    this.qSection = qSection;
    decode(decodeRdata);
}
 
源代码21 项目: jdk8u-jdk   文件: Connections.java
/**
 * Retrieves a PooledConnection from this list of connections.
 * Use an existing one if one is idle, or create one if the list's
 * max size hasn't been reached. If max size has been reached, wait
 * for a PooledConnection to be returned, or one to be removed (thus
 * not reaching the max size any longer).
 *
 * @param timeout if > 0, msec to wait until connection is available
 * @param factory creates the PooledConnection if one needs to be created
 *
 * @return A non-null PooledConnection
 * @throws NamingException PooledConnection cannot be created, because this
 * thread was interrupted while it waited for an available connection,
 * or if it timed out while waiting, or the creation of a connection
 * resulted in an error.
 */
synchronized PooledConnection get(long timeout,
    PooledConnectionFactory factory) throws NamingException {
    PooledConnection conn;
    long start = (timeout > 0 ? System.currentTimeMillis() : 0);
    long waittime = timeout;

    d("get(): before");
    while ((conn = getOrCreateConnection(factory)) == null) {
        if (timeout > 0 && waittime <= 0) {
            throw new CommunicationException(
                "Timeout exceeded while waiting for a connection: " +
                timeout + "ms");
        }
        try {
            d("get(): waiting");
            if (waittime > 0) {
                wait(waittime);  // Wait until one is released or removed
            } else {
                wait();
            }
        } catch (InterruptedException e) {
            throw new InterruptedNamingException(
                "Interrupted while waiting for a connection");
        }
        // Check whether we timed out
        if (timeout > 0) {
            long now = System.currentTimeMillis();
            waittime = timeout - (now - start);
        }
    }

    d("get(): after");
    return conn;
}
 
源代码22 项目: openjdk-jdk8u   文件: ResourceRecord.java
private Object decodeRdata(int pos) throws CommunicationException {
    if (rrclass == CLASS_INTERNET) {
        switch (rrtype) {
        case TYPE_A:
            return decodeA(pos);
        case TYPE_AAAA:
            return decodeAAAA(pos);
        case TYPE_CNAME:
        case TYPE_NS:
        case TYPE_PTR:
            return decodeName(pos);
        case TYPE_MX:
            return decodeMx(pos);
        case TYPE_SOA:
            return decodeSoa(pos);
        case TYPE_SRV:
            return decodeSrv(pos);
        case TYPE_NAPTR:
            return decodeNaptr(pos);
        case TYPE_TXT:
            return decodeTxt(pos);
        case TYPE_HINFO:
            return decodeHinfo(pos);
        }
    }
    // Unknown RR type/class
    if (debug) {
        dprint("Unknown RR type for RR data: " + rrtype + " rdlen=" + rdlen
               + ", pos=" + pos +", msglen=" + msg.length + ", remaining="
               + (msg.length-pos));
    }
    byte[] rd = new byte[rdlen];
    System.arraycopy(msg, pos, rd, 0, rdlen);
    return rd;
}
 
源代码23 项目: jdk8u_jdk   文件: Connections.java
/**
 * Retrieves a PooledConnection from this list of connections.
 * Use an existing one if one is idle, or create one if the list's
 * max size hasn't been reached. If max size has been reached, wait
 * for a PooledConnection to be returned, or one to be removed (thus
 * not reaching the max size any longer).
 *
 * @param timeout if > 0, msec to wait until connection is available
 * @param factory creates the PooledConnection if one needs to be created
 *
 * @return A non-null PooledConnection
 * @throws NamingException PooledConnection cannot be created, because this
 * thread was interrupted while it waited for an available connection,
 * or if it timed out while waiting, or the creation of a connection
 * resulted in an error.
 */
synchronized PooledConnection get(long timeout,
    PooledConnectionFactory factory) throws NamingException {
    PooledConnection conn;
    long start = (timeout > 0 ? System.currentTimeMillis() : 0);
    long waittime = timeout;

    d("get(): before");
    while ((conn = getOrCreateConnection(factory)) == null) {
        if (timeout > 0 && waittime <= 0) {
            throw new CommunicationException(
                "Timeout exceeded while waiting for a connection: " +
                timeout + "ms");
        }
        try {
            d("get(): waiting");
            if (waittime > 0) {
                wait(waittime);  // Wait until one is released or removed
            } else {
                wait();
            }
        } catch (InterruptedException e) {
            throw new InterruptedNamingException(
                "Interrupted while waiting for a connection");
        }
        // Check whether we timed out
        if (timeout > 0) {
            long now = System.currentTimeMillis();
            waittime = timeout - (now - start);
        }
    }

    d("get(): after");
    return conn;
}
 
源代码24 项目: big-c   文件: TestLdapGroupsMapping.java
@Test
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 
}
 
源代码25 项目: openjdk-jdk8u   文件: Connections.java
/**
 * Retrieves a PooledConnection from this list of connections.
 * Use an existing one if one is idle, or create one if the list's
 * max size hasn't been reached. If max size has been reached, wait
 * for a PooledConnection to be returned, or one to be removed (thus
 * not reaching the max size any longer).
 *
 * @param timeout if > 0, msec to wait until connection is available
 * @param factory creates the PooledConnection if one needs to be created
 *
 * @return A non-null PooledConnection
 * @throws NamingException PooledConnection cannot be created, because this
 * thread was interrupted while it waited for an available connection,
 * or if it timed out while waiting, or the creation of a connection
 * resulted in an error.
 */
synchronized PooledConnection get(long timeout,
    PooledConnectionFactory factory) throws NamingException {
    PooledConnection conn;
    long start = (timeout > 0 ? System.currentTimeMillis() : 0);
    long waittime = timeout;

    d("get(): before");
    while ((conn = getOrCreateConnection(factory)) == null) {
        if (timeout > 0 && waittime <= 0) {
            throw new CommunicationException(
                "Timeout exceeded while waiting for a connection: " +
                timeout + "ms");
        }
        try {
            d("get(): waiting");
            if (waittime > 0) {
                wait(waittime);  // Wait until one is released or removed
            } else {
                wait();
            }
        } catch (InterruptedException e) {
            throw new InterruptedNamingException(
                "Interrupted while waiting for a connection");
        }
        // Check whether we timed out
        if (timeout > 0) {
            long now = System.currentTimeMillis();
            waittime = timeout - (now - start);
        }
    }

    d("get(): after");
    return conn;
}
 
源代码26 项目: openjdk-jdk8u-backup   文件: ResourceRecord.java
ResourceRecord(byte[] msg, int msgLen, int offset,
               boolean qSection, boolean decodeRdata)
        throws CommunicationException {

    this.msg = msg;
    this.msgLen = msgLen;
    this.offset = offset;
    this.qSection = qSection;
    decode(decodeRdata);
}
 
源代码27 项目: openjdk-jdk8u-backup   文件: ResourceRecord.java
private Object decodeRdata(int pos) throws CommunicationException {
    if (rrclass == CLASS_INTERNET) {
        switch (rrtype) {
        case TYPE_A:
            return decodeA(pos);
        case TYPE_AAAA:
            return decodeAAAA(pos);
        case TYPE_CNAME:
        case TYPE_NS:
        case TYPE_PTR:
            return decodeName(pos);
        case TYPE_MX:
            return decodeMx(pos);
        case TYPE_SOA:
            return decodeSoa(pos);
        case TYPE_SRV:
            return decodeSrv(pos);
        case TYPE_NAPTR:
            return decodeNaptr(pos);
        case TYPE_TXT:
            return decodeTxt(pos);
        case TYPE_HINFO:
            return decodeHinfo(pos);
        }
    }
    // Unknown RR type/class
    if (debug) {
        dprint("Unknown RR type for RR data: " + rrtype + " rdlen=" + rdlen
               + ", pos=" + pos +", msglen=" + msg.length + ", remaining="
               + (msg.length-pos));
    }
    byte[] rd = new byte[rdlen];
    System.arraycopy(msg, pos, rd, 0, rdlen);
    return rd;
}
 
@Test
@SuppressWarnings("unchecked")
public void verifyParsePoolingDefaults() {
    ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("/ldap-namespace-config-pooling-defaults.xml");

    ContextSource outerContextSource = ctx.getBean(ContextSource.class);
    assertThat(outerContextSource).isNotNull();
    assertThat(outerContextSource instanceof TransactionAwareContextSourceProxy).isTrue();

    ContextSource pooledContextSource = ((TransactionAwareContextSourceProxy) outerContextSource).getTarget();
    assertThat(pooledContextSource).isNotNull();
    assertThat(pooledContextSource instanceof PoolingContextSource).isTrue();

    Object objectFactory = getInternalState(pooledContextSource, "dirContextPoolableObjectFactory");
    assertThat(getInternalState(objectFactory, "contextSource")).isNotNull();
    assertThat(getInternalState(objectFactory, "dirContextValidator")).isNull();
    Set<Class<? extends Throwable>> nonTransientExceptions =
            (Set<Class<? extends Throwable>>) getInternalState(objectFactory, "nonTransientExceptions");
    assertThat(nonTransientExceptions).hasSize(1);
    assertThat(nonTransientExceptions.contains(CommunicationException.class)).isTrue();

    GenericKeyedObjectPool objectPool = (GenericKeyedObjectPool) getInternalState(pooledContextSource, "keyedObjectPool");
    assertThat(objectPool.getMaxActive()).isEqualTo(8);
    assertThat(objectPool.getMaxTotal()).isEqualTo(-1);
    assertThat(objectPool.getMaxIdle()).isEqualTo(8);
    assertThat(objectPool.getMaxWait()).isEqualTo(-1);
    assertThat(objectPool.getMinIdle()).isEqualTo(0);
    assertThat(objectPool.getWhenExhaustedAction()).isEqualTo((byte)1);
}
 
源代码29 项目: jdk8u_jdk   文件: ResourceRecord.java
private String decodeSrv(int pos) throws CommunicationException {
    int priority = getUShort(pos);
    pos += 2;
    int weight =   getUShort(pos);
    pos += 2;
    int port =     getUShort(pos);
    pos += 2;
    DnsName target = decodeName(pos);
    return (priority + " " + weight + " " + port + " " + target);
}
 
源代码30 项目: big-c   文件: TestLdapGroupsMapping.java
@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
  doTestGetGroups(Arrays.asList(new String[] {}), 
      1 + LdapGroupsMapping.RECONNECT_RETRY_COUNT); // 1 is the first normal call
}
 
 类所在包
 同包方法