當前位置: 首頁>>代碼示例>>Java>>正文


Java BOSHException類代碼示例

本文整理匯總了Java中org.igniterealtime.jbosh.BOSHException的典型用法代碼示例。如果您正苦於以下問題:Java BOSHException類的具體用法?Java BOSHException怎麽用?Java BOSHException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


BOSHException類屬於org.igniterealtime.jbosh包,在下文中一共展示了BOSHException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: interpretLegacyHTTPCodes

import org.igniterealtime.jbosh.BOSHException; //導入依賴的package包/類
@Test(timeout=5000)
public void interpretLegacyHTTPCodes() throws Exception {
    logTestStart();
    // Initiate a new session with a legacy response
    session.send(ComposableBody.builder().build());
    StubConnection conn = cm.awaitConnection();
    AbstractBody scr = ComposableBody.builder()
            .setAttribute(Attributes.SID, "123XYZ")
            .setAttribute(Attributes.WAIT, "1")
            .build();
    conn.sendResponseWithStatus(scr, 400);

    // This should not work, since the ver attr indicated legacy CM
    try {
        session.send(ComposableBody.builder().build());
        conn = cm.awaitConnection();
        conn.sendResponse(ComposableBody.builder()
                .setAttribute(Attributes.SID, "123XYZ")
                .build());
        fail("Did not catch legacy CM terminal binding error");
    } catch (BOSHException boshx) {
        // Good.
    }

    assertValidators(scr);
}
 
開發者ID:igniterealtime,項目名稱:jbosh,代碼行數:27,代碼來源:XEP0124Section17Test.java

示例2: ignoreNonLegacyHTTPCodes

import org.igniterealtime.jbosh.BOSHException; //導入依賴的package包/類
@Test(timeout=5000)
public void ignoreNonLegacyHTTPCodes() throws Exception {
    logTestStart();
    // Initiate a new session
    session.send(ComposableBody.builder().build());
    StubConnection conn = cm.awaitConnection();
    AbstractBody scr = ComposableBody.builder()
            .setAttribute(Attributes.SID, "123XYZ")
            .setAttribute(Attributes.WAIT, "1")
            .setAttribute(Attributes.VER, "1.8")
            .build();
    conn.sendResponseWithStatus(scr, 400);

    // This should work, since the ver attr indicated non-legacy CM
    try {
        session.send(ComposableBody.builder().build());
        conn = cm.awaitConnection();
        conn.sendResponse(ComposableBody.builder()
                .setAttribute(Attributes.SID, "123XYZ")
                .build());
    } catch (BOSHException boshx) {
        fail("Caught boshx: " + boshx.getMessage());
    }

    assertValidators(scr);
}
 
開發者ID:igniterealtime,項目名稱:jbosh,代碼行數:27,代碼來源:XEP0124Section17Test.java

示例3: testDeprecatedHTTPError

import org.igniterealtime.jbosh.BOSHException; //導入依賴的package包/類
@Test(timeout=5000)
public void testDeprecatedHTTPError() throws Exception {
    logTestStart();
    // Initiate a new session
    session.send(ComposableBody.builder().build());
    StubConnection conn = cm.awaitConnection();
    AbstractBody scr = ComposableBody.builder()
            .setAttribute(Attributes.SID, "123XYZ")
            .setAttribute(Attributes.WAIT, "1")
            .build();
    conn.sendResponseWithStatus(scr, 400);

    // Attempts to send anything else should fail
    try {
        session.send(ComposableBody.builder().build());
        conn = cm.awaitConnection();
        conn.sendResponse(ComposableBody.builder()
                .setAttribute(Attributes.SID, "123XYZ")
                .build());
        fail("Shouldn't be able to send after terminal binding error");
    } catch (BOSHException boshx) {
        // Good
    }
    assertValidators(scr);
}
 
開發者ID:igniterealtime,項目名稱:jbosh,代碼行數:26,代碼來源:XEP0124Section17Test.java

示例4: performanceTest

import org.igniterealtime.jbosh.BOSHException; //導入依賴的package包/類
public void performanceTest() throws BOSHException {
    String basicStr = loadResource("BodyTest.basic");
    // Warm up the codepath
    int iterations = 100000;
    int warmup = Math.max(1000, iterations / 10);
    for (int i=0; i<warmup; i++) {
        StaticBody.fromString(basicStr);
    }
    // Now time it
    long start = System.currentTimeMillis();
    for (int i=0; i<iterations; i++) {
        StaticBody.fromString(basicStr);
    }
    long end = System.currentTimeMillis();
    long delta = end - start;
    LOG.info("Ran " + iterations + " iterations in " + delta + " ms. ");
    if (delta > 0) {
        LOG.info("    That's " + (iterations * 1000F / delta) + "/s");
    }
}
 
開發者ID:igniterealtime,項目名稱:jbosh,代碼行數:21,代碼來源:StaticBodyTest.java

示例5: sendElement

import org.igniterealtime.jbosh.BOSHException; //導入依賴的package包/類
private void sendElement(Element element) {
    try {
        send(ComposableBody.builder().setPayloadXML(element.toXML().toString()).build());
        if (element instanceof Stanza) {
            firePacketSendingListeners((Stanza) element);
        }
    }
    catch (BOSHException e) {
        LOGGER.log(Level.SEVERE, "BOSHException in sendStanzaInternal", e);
    }
}
 
開發者ID:TTalkIM,項目名稱:Smack,代碼行數:12,代碼來源:XMPPBOSHConnection.java

示例6: send

import org.igniterealtime.jbosh.BOSHException; //導入依賴的package包/類
/**
 * Send a HTTP request to the connection manager with the provided body element.
 * 
 * @param body the body which will be sent.
 */
protected void send(ComposableBody body) throws BOSHException {
    if (!connected) {
        throw new IllegalStateException("Not connected to a server!");
    }
    if (body == null) {
        throw new NullPointerException("Body mustn't be null!");
    }
    if (sessionID != null) {
        body = body.rebuild().setAttribute(
                BodyQName.create(BOSH_URI, "sid"), sessionID).build();
    }
    client.send(body);
}
 
開發者ID:TTalkIM,項目名稱:Smack,代碼行數:19,代碼來源:XMPPBOSHConnection.java

示例7: validateSubsequentPause

import org.igniterealtime.jbosh.BOSHException; //導入依賴的package包/類
/**
 * If the connection manager did not specify a 'maxpause' attribute at the
 * start of the session then the client MUST NOT send a 'pause' attribute
 * during the session.
 *
 * @param idx message number (zero-based)
 * @param request message to validate
 */
private void validateSubsequentPause(
        final int idx,
        final Node request,
        final Node previous) {
    AbstractBody scr = sessionCreationResponse.get();
    if (scr == null) {
        // Not checking this
        return;
    }

    try {
        // Check the current node:
        AttrPause pause = AttrPause.createFromString(
                request.getBody().getAttribute(Attributes.PAUSE));
        if (pause != null) {
            AttrMaxPause maxPause = AttrMaxPause.createFromString(
                    scr.getAttribute(Attributes.MAXPAUSE));
            assertNotNull("Request #" + idx + " can only use pause when "
                    + "advertized in session creation response", maxPause);
            assertTrue(pause.intValue() < maxPause.intValue());
        }

        // Check the previous node
        AttrPause prevPause = AttrPause.createFromString(
                previous.getBody().getAttribute(Attributes.PAUSE));
        if (prevPause != null) {
            long delta = request.getTime() - previous.getTime();
            if (delta > prevPause.getInMilliseconds()) {
                fail("Request #" + idx + " was sent too late relative to "
                    + "the previous pause message (delta=" + delta
                    + ", pause=" + prevPause.getInMilliseconds() + ")");
            }
        }
    } catch (BOSHException boshx) {
        fail("Could not parse pause/maxpause: " + boshx.getMessage());
    }
}
 
開發者ID:igniterealtime,項目名稱:jbosh,代碼行數:46,代碼來源:RequestValidator.java

示例8: unknownContentTypeHeader

import org.igniterealtime.jbosh.BOSHException; //導入依賴的package包/類
@Test(timeout=5000)
public void unknownContentTypeHeader() throws Exception {
    logTestStart();
    // Create an artificial response with a random content type
    Map<String,String> headers = new HashMap<String,String>();
    headers.put("Content-type", "foo/bar");

    session.send(ComposableBody.builder()
            .build());
    StubConnection conn = cm.awaitConnection();
    AbstractBody scr = ComposableBody.builder()
            .setAttribute(Attributes.SID, "123XYZ")
            .setAttribute(Attributes.WAIT, "1")
            .setAttribute(
                BodyQName.createBOSH("unknownBOSH"), "val")
            .setAttribute(
                BodyQName.create("http://unknown.com/", "unknown"), "val")
            .build();
    conn.sendResponseWithStatusAndHeaders(scr, 200, headers);

    // We should still be able to use the session
    try {
        session.send(ComposableBody.builder()
                .build());
        conn = cm.awaitConnection();
        conn.sendResponse(ComposableBody.builder().build());
    } catch (BOSHException boshx) {
        fail("Could not handle unknown Content-type");
    }

    assertValidators(scr);
}
 
開發者ID:igniterealtime,項目名稱:jbosh,代碼行數:33,代碼來源:XEP0124Section05Test.java

示例9: StubRequest

import org.igniterealtime.jbosh.BOSHException; //導入依賴的package包/類
StubRequest(final IHttpRequest request) {
    method = request.getMethod();
    secure = request.isSecure();

    // Create a map of the request headers
    headers = new HashMap<String,String>();

    @SuppressWarnings("unchecked")
    Enumeration<String> headerNames = request.getHeaderNames();
    
    while (headerNames.hasMoreElements()) {
        String headerName = headerNames.nextElement();
        headers.put(headerName, request.getHeader(headerName));
    }
    
    // Read in the message body
    try {
        byte[] data = request.getBlockingBody().readBytes();
        String encoding = request.getHeader("Content-Encoding");
        if (ZLIBCodec.getID().equalsIgnoreCase(encoding)) {
            data = ZLIBCodec.decode(data);
        } else if (GZIPCodec.getID().equalsIgnoreCase(encoding)) {
            data = GZIPCodec.decode(data);
        }
        String bodyStr = new String(data);
        body = StaticBody.fromString(bodyStr);
    } catch (IOException iox) {
        throw(new IllegalStateException("Couldn't load request body", iox));
    } catch (BOSHException boshx) {
        throw(new IllegalStateException("Couldn't load request body", boshx));
    }
}
 
開發者ID:igniterealtime,項目名稱:jbosh,代碼行數:33,代碼來源:StubRequest.java

示例10: testExceptionOnUnparseable

import org.igniterealtime.jbosh.BOSHException; //導入依賴的package包/類
@Test
public void testExceptionOnUnparseable() {
    try {
        AttrVersion.createFromString("foo bar");
        fail("Should have thrown exception on unparsable input");
    } catch (BOSHException boshx) {
        // Good.
    }
}
 
開發者ID:igniterealtime,項目名稱:jbosh,代碼行數:10,代碼來源:AttrVersionTest.java

示例11: testExceptionOnNoMajor

import org.igniterealtime.jbosh.BOSHException; //導入依賴的package包/類
@Test
public void testExceptionOnNoMajor() {
    try {
        AttrVersion.createFromString(".0");
        fail("Should have thrown exception on bad major value");
    } catch (BOSHException boshx) {
        // Good.
    }
}
 
開發者ID:igniterealtime,項目名稱:jbosh,代碼行數:10,代碼來源:AttrVersionTest.java

示例12: testExceptionOnBadMajor

import org.igniterealtime.jbosh.BOSHException; //導入依賴的package包/類
@Test
public void testExceptionOnBadMajor() {
    try {
        AttrVersion.createFromString("-1.0");
        fail("Should have thrown exception on bad major value");
    } catch (BOSHException boshx) {
        // Good.
    }
}
 
開發者ID:igniterealtime,項目名稱:jbosh,代碼行數:10,代碼來源:AttrVersionTest.java

示例13: testExceptionOnNoMinor

import org.igniterealtime.jbosh.BOSHException; //導入依賴的package包/類
@Test
public void testExceptionOnNoMinor() {
    try {
        AttrVersion.createFromString("0.");
        fail("Should have thrown exception on bad major value");
    } catch (BOSHException boshx) {
        // Good.
    }
}
 
開發者ID:igniterealtime,項目名稱:jbosh,代碼行數:10,代碼來源:AttrVersionTest.java

示例14: testExceptionOnBadMinor

import org.igniterealtime.jbosh.BOSHException; //導入依賴的package包/類
@Test
public void testExceptionOnBadMinor() {
    try {
        AttrVersion.createFromString("0.-1");
        fail("Should have thrown exception on bad major value");
    } catch (BOSHException boshx) {
        // Good.
    }
}
 
開發者ID:igniterealtime,項目名稱:jbosh,代碼行數:10,代碼來源:AttrVersionTest.java

示例15: testComparison

import org.igniterealtime.jbosh.BOSHException; //導入依賴的package包/類
@Test
public void testComparison() throws BOSHException {
    AttrVersion attr1_0 = AttrVersion.createFromString("1.0");
    AttrVersion attr1_0_2 = AttrVersion.createFromString("1.0");
    AttrVersion attr1_10 = AttrVersion.createFromString("1.10");
    AttrVersion attr10_0 = AttrVersion.createFromString("10.0");
    AttrVersion attr1_1 = AttrVersion.createFromString("1.1");
    assertTrue("1.0 == 1.0", attr1_0.compareTo(attr1_0_2) == 0);
    assertTrue("1.0 < 1.10", attr1_0.compareTo(attr1_10) < 0);
    assertTrue("1.10 > 1.0", attr1_10.compareTo(attr1_0) > 0);
    assertTrue("1.10 < 10.0", attr1_10.compareTo(attr10_0) < 0);
    assertTrue("10.0 > 1.10", attr10_0.compareTo(attr1_10) > 0);
    assertTrue("1.1 < 1.10", attr1_1.compareTo(attr1_10) < 0);
}
 
開發者ID:igniterealtime,項目名稱:jbosh,代碼行數:15,代碼來源:AttrVersionTest.java


注:本文中的org.igniterealtime.jbosh.BOSHException類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。