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


Java TransportException類代碼示例

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


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

示例1: pourAll

import org.apache.qpid.proton.engine.TransportException; //導入依賴的package包/類
/**
 * Pours the contents of {@code source} into {@code destinationTransportInput}, calling
 * the TransportInput many times if necessary.  If the TransportInput returns a {@link org.apache.qpid.proton.engine.TransportResult}
 * other than ok, data may remain in source.
 */
public static int pourAll(ByteBuffer source, TransportInput destinationTransportInput) throws TransportException
{
    int capacity = destinationTransportInput.capacity();
    if (capacity == Transport.END_OF_STREAM)
    {
        if (source.hasRemaining()) {
            throw new IllegalStateException("Destination has reached end of stream: " +
                                            destinationTransportInput);
        } else {
            return Transport.END_OF_STREAM;
        }
    }

    int total = source.remaining();

    while(source.hasRemaining() && destinationTransportInput.capacity() > 0)
    {
        pour(source, destinationTransportInput.tail());
        destinationTransportInput.process();
    }

    return total - source.remaining();
}
 
開發者ID:apache,項目名稱:qpid-proton-j,代碼行數:29,代碼來源:ByteBufferUtils.java

示例2: readPemObject

import org.apache.qpid.proton.engine.TransportException; //導入依賴的package包/類
private Object readPemObject(String pemFile)
{
    Reader reader = null;
    Object pemParser = null;
    Object pemObject = null;

    try
    {
        reader = new FileReader(pemFile);
        pemParser = pemParserCons.newInstance(reader); // = new PEMParser(reader);
        pemObject = pemReadMethod.invoke(pemParser); // = pemParser.readObject();
    }
    catch (IOException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | InstantiationException e)
    {
        _logger.log(Level.SEVERE, "Unable to read PEM object. Perhaps you need the unlimited strength libraries in <java-home>/jre/lib/security/ ?", e);
        throw new TransportException("Unable to read PEM object from file " + pemFile, e);
    }
    finally
    {
        closeSafely(reader);
    }

    return pemObject;
}
 
開發者ID:apache,項目名稱:qpid-proton-j,代碼行數:25,代碼來源:SslEngineFacadeFactory.java

示例3: process

import org.apache.qpid.proton.engine.TransportException; //導入依賴的package包/類
@Override
public void process() throws TransportException
{
    if (_tail_closed) throw new TransportException("tail closed");

    _inputBuffer.flip();

    try {
        unwrapInput();
    } catch (SSLException e) {
        _logger.log(Level.WARNING, e.getMessage());
        _inputBuffer.position(_inputBuffer.limit());
        _tail_closed = true;
    } finally {
        _inputBuffer.compact();
    }
}
 
開發者ID:apache,項目名稱:qpid-proton-j,代碼行數:18,代碼來源:SimpleSslTransportWrapper.java

示例4: initTransportWrapperOnFirstIO

import org.apache.qpid.proton.engine.TransportException; //導入依賴的package包/類
private void initTransportWrapperOnFirstIO()
{
    try {
        if (_initException == null && _transportWrapper == null)
        {
            SslTransportWrapper sslTransportWrapper = new SimpleSslTransportWrapper
                (_protonSslEngineProvider.createSslEngine(_peerDetails),
                 _inputProcessor, _outputProcessor);

            if (_domain.allowUnsecuredClient() && _domain.getMode() == SslDomain.Mode.SERVER)
            {
                TransportWrapper plainTransportWrapper = new PlainTransportWrapper
                    (_outputProcessor, _inputProcessor);
                _transportWrapper = new SslHandshakeSniffingTransportWrapper
                    (sslTransportWrapper, plainTransportWrapper);
            }
            else
            {
                _transportWrapper = sslTransportWrapper;
            }
        }
    } catch (TransportException e) {
        _initException = e;
    }
}
 
開發者ID:apache,項目名稱:qpid-proton-j,代碼行數:26,代碼來源:SslImpl.java

示例5: process

import org.apache.qpid.proton.engine.TransportException; //導入依賴的package包/類
@Override
public void process() throws TransportException
{
    if (isDeterminationMade())
    {
        _selectedTransportWrapper.process();
    }
    else if (_determinationBuffer.remaining() == 0)
    {
        _determinationBuffer.flip();
        byte[] bytesInput = new byte[_determinationBuffer.remaining()];
        _determinationBuffer.get(bytesInput);
        makeDetermination(bytesInput);
        _determinationBuffer.rewind();

        // TODO what if the selected transport has insufficient capacity?? Maybe use pour, and then try to finish pouring next time round.
        _selectedTransportWrapper.tail().put(_determinationBuffer);
        _selectedTransportWrapper.process();
    } else if (_tail_closed) {
        throw new TransportException("connection aborted");
    }
}
 
開發者ID:apache,項目名稱:qpid-proton-j,代碼行數:23,代碼來源:HandshakeSniffingTransportWrapper.java

示例6: testInputOfFrameWithInvalidSizeExceedingMinMaxFrameSize

import org.apache.qpid.proton.engine.TransportException; //導入依賴的package包/類
@Test
public void testInputOfFrameWithInvalidSizeExceedingMinMaxFrameSize()
{
    sendAmqpSaslHeader(_frameParserWithMockDecoder);

    // http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-security-v1.0-os.html#doc-idp43536
    // Description: '513byte sized' SASL frame header
    byte[] oversizedSaslFrameHeader = new byte[] { (byte) 0x00, 0x00, 0x02, 0x01, 0x02, 0x01, 0x00, 0x00 };

    try {
        _frameParserWithMockDecoder.input(ByteBuffer.wrap(oversizedSaslFrameHeader));
        fail("expected exception");
    } catch (TransportException e) {
        assertThat(e.getMessage(), containsString("frame size 513 larger than maximum"));
    }
}
 
開發者ID:apache,項目名稱:qpid-proton-j,代碼行數:17,代碼來源:SaslFrameParserTest.java

示例7: testInputOfFrameWithInvalidSizeWhenSpecifyingLargeMaxFrameSize

import org.apache.qpid.proton.engine.TransportException; //導入依賴的package包/類
@Test
public void testInputOfFrameWithInvalidSizeWhenSpecifyingLargeMaxFrameSize()
{
    SaslFrameParser frameParserWithLargeMaxSize = new SaslFrameParser(_mockSaslFrameHandler, _mockDecoder, 2017);
    sendAmqpSaslHeader(frameParserWithLargeMaxSize);

    // http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-security-v1.0-os.html#doc-idp43536
    // Description: '2057byte sized' SASL frame header
    byte[] oversizedSaslFrameHeader = new byte[] { (byte) 0x00, 0x00, 0x08, 0x09, 0x02, 0x01, 0x00, 0x00 };

    try {
        frameParserWithLargeMaxSize.input(ByteBuffer.wrap(oversizedSaslFrameHeader));
        fail("expected exception");
    } catch (TransportException e) {
        assertThat(e.getMessage(), containsString("frame size 2057 larger than maximum SASL frame size 2017"));
    }
}
 
開發者ID:apache,項目名稱:qpid-proton-j,代碼行數:18,代碼來源:SaslFrameParserTest.java

示例8: testInputOfFrameWithInvalidSizeBelowMinimumPossible

import org.apache.qpid.proton.engine.TransportException; //導入依賴的package包/類
@Test
public void testInputOfFrameWithInvalidSizeBelowMinimumPossible()
{
    sendAmqpSaslHeader(_frameParserWithMockDecoder);

    // http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-security-v1.0-os.html#doc-idp43536
    // Description: '7byte sized' SASL frame header
    byte[] undersizedSaslFrameHeader = new byte[] { (byte) 0x00, 0x00, 0x00, 0x07, 0x02, 0x01, 0x00, 0x00 };

    try {
        _frameParserWithMockDecoder.input(ByteBuffer.wrap(undersizedSaslFrameHeader));
        fail("expected exception");
    } catch (TransportException e) {
        assertThat(e.getMessage(), containsString("frame size 7 smaller than minimum"));
    }
}
 
開發者ID:apache,項目名稱:qpid-proton-j,代碼行數:17,代碼來源:SaslFrameParserTest.java

示例9: testInputOfFrameWithInvalidDoffBelowMinimumPossible

import org.apache.qpid.proton.engine.TransportException; //導入依賴的package包/類
@Test
public void testInputOfFrameWithInvalidDoffBelowMinimumPossible()
{
    sendAmqpSaslHeader(_frameParserWithMockDecoder);

    // http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-security-v1.0-os.html#doc-idp43536
    // Description: '8byte sized' SASL frame header with invalid doff of 1[*4 = 4bytes]
    byte[] underMinDoffSaslFrameHeader = new byte[] { (byte) 0x00, 0x00, 0x00, 0x08, 0x01, 0x01, 0x00, 0x00 };

    try {
        _frameParserWithMockDecoder.input(ByteBuffer.wrap(underMinDoffSaslFrameHeader));
        fail("expected exception");
    } catch (TransportException e) {
        assertThat(e.getMessage(), containsString("data offset 4 smaller than minimum"));
    }
}
 
開發者ID:apache,項目名稱:qpid-proton-j,代碼行數:17,代碼來源:SaslFrameParserTest.java

示例10: testInputOfFrameWithInvalidDoffAboveMaximumPossible

import org.apache.qpid.proton.engine.TransportException; //導入依賴的package包/類
@Test
public void testInputOfFrameWithInvalidDoffAboveMaximumPossible()
{
    sendAmqpSaslHeader(_frameParserWithMockDecoder);

    // http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-security-v1.0-os.html#doc-idp43536
    // Description: '8byte sized' SASL frame header with invalid doff of 3[*4 = 12bytes]
    byte[] overFrameSizeDoffSaslFrameHeader = new byte[] { (byte) 0x00, 0x00, 0x00, 0x08, 0x03, 0x01, 0x00, 0x00 };

    try {
        _frameParserWithMockDecoder.input(ByteBuffer.wrap(overFrameSizeDoffSaslFrameHeader));
        fail("expected exception");
    } catch (TransportException e) {
        assertThat(e.getMessage(), containsString("data offset 12 larger than the frame size 8"));
    }
}
 
開發者ID:apache,項目名稱:qpid-proton-j,代碼行數:17,代碼來源:SaslFrameParserTest.java

示例11: process

import org.apache.qpid.proton.engine.TransportException; //導入依賴的package包/類
@Override
public void process() throws TransportException
{
    _processCount++;

    initIntermediateBuffer();

    if(_nextError != null)
    {
        throw new TransportException(_nextError);
    }

    _buffer.flip();
    byte[] receivedInputBuffer = new byte[_buffer.remaining()];
    _buffer.get(receivedInputBuffer);
    _buffer.compact();
    _receivedInput.append(new String(receivedInputBuffer));
}
 
開發者ID:apache,項目名稱:qpid-proton-j,代碼行數:19,代碼來源:RememberingTransportInput.java

示例12: testTooFewBytesToMakeDetermination

import org.apache.qpid.proton.engine.TransportException; //導入依賴的package包/類
@Test
public void testTooFewBytesToMakeDetermination()
{
    byte[] sourceBuffer = new byte[] {0x00};

    try
    {
        _sniffingWrapper.tail().put(sourceBuffer);
        _sniffingWrapper.close_tail();

        _expectedException.expect(TransportException.class);
        _sniffingWrapper.process();
    }
    finally
    {
        verifyZeroInteractions(_secureTransportWrapper, _plainTransportWrapper);
    }
}
 
開發者ID:apache,項目名稱:qpid-proton-j,代碼行數:19,代碼來源:SslHandshakeSniffingTransportWrapperTest.java

示例13: pumpInbound

import org.apache.qpid.proton.engine.TransportException; //導入依賴的package包/類
private void pumpInbound(ByteBuffer bytes) {
  if (failed) {
    LOG.trace("Skipping processing of data following transport error: {0}", bytes);
    return;
  }

  // Lets push bytes from vert.x to proton engine.
  ByteBuffer inputBuffer = transport.getInputBuffer();
  while (bytes.hasRemaining() && inputBuffer.hasRemaining() && !failed) {
    inputBuffer.put(bytes.get());
    try {
      transport.processInput().checkIsOk();
    } catch (TransportException te) {
      failed = true;
      LOG.trace("Exception while processing transport input", te);
    }
  }
}
 
開發者ID:vert-x3,項目名稱:vertx-proton,代碼行數:19,代碼來源:ProtonTransport.java

示例14: oldApiCheckStateBeforeInput

import org.apache.qpid.proton.engine.TransportException; //導入依賴的package包/類
/**
 * This method is public as it is used by Python layer.
 * @see org.apache.qpid.proton.engine.Transport#input(byte[], int, int)
 */
public TransportResult oldApiCheckStateBeforeInput(int inputLength)
{
    _lastTransportResult.checkIsOk();
    if(inputLength == 0)
    {
        if(_connectionEndpoint == null || _connectionEndpoint.getRemoteState() != EndpointState.CLOSED)
        {
            return TransportResultFactory.error(new TransportException("Unexpected EOS when remote connection not closed: connection aborted"));
        }
    }
    return TransportResultFactory.ok();
}
 
開發者ID:apache,項目名稱:qpid-proton-j,代碼行數:17,代碼來源:TransportImpl.java

示例15: processInput

import org.apache.qpid.proton.engine.TransportException; //導入依賴的package包/類
@Override
public TransportResult processInput()
{
    try {
        process();
        return TransportResultFactory.ok();
    } catch (TransportException e) {
        return TransportResultFactory.error(e);
    }
}
 
開發者ID:apache,項目名稱:qpid-proton-j,代碼行數:11,代碼來源:TransportImpl.java


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