@Override public OutputStream createOutgoingStream(String streamID, Jid initiator, Jid target) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { InBandBytestreamSession session = this.manager.establishSession(target, streamID); session.setCloseBothStreamsEnabled(true); return session.getOutputStream(); }
/** * Test the output stream flush() method. * * @throws Exception should not happen */ @Test public void shouldSendThirtyDataPackets() throws Exception { byte[] controlData = new byte[blockSize * 3]; InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream, initiatorJID); // verify the data packets for (int i = 0; i < controlData.length; i++) { protocol.addResponse(null, incrementingSequence); } OutputStream outputStream = session.getOutputStream(); for (byte b : controlData) { outputStream.write(b); outputStream.flush(); } protocol.verifyAll(); }
/** * Test successive calls to the output stream flush() method. * * @throws Exception should not happen */ @Test public void shouldSendNothingOnSuccessiveCallsToFlush() throws Exception { byte[] controlData = new byte[blockSize * 3]; InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream, initiatorJID); // verify the data packets protocol.addResponse(null, incrementingSequence); protocol.addResponse(null, incrementingSequence); protocol.addResponse(null, incrementingSequence); OutputStream outputStream = session.getOutputStream(); outputStream.write(controlData); outputStream.flush(); outputStream.flush(); outputStream.flush(); protocol.verifyAll(); }
initiatorJID); OutputStream outputStream = session.getOutputStream(); outputStream.write(controlData); outputStream.flush();
/** * Test successive calls to the output stream flush() method. * * @throws Exception should not happen */ @Test public void shouldSendNothingOnSuccessiveCallsToFlush() throws Exception { byte[] controlData = new byte[blockSize * 3]; InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream, initiatorJID); // set acknowledgments for the data packets IQ resultIQ = IBBPacketUtils.createResultIQ(initiatorJID, targetJID); protocol.addResponse(resultIQ, incrementingSequence); protocol.addResponse(resultIQ, incrementingSequence); protocol.addResponse(resultIQ, incrementingSequence); OutputStream outputStream = session.getOutputStream(); outputStream.write(controlData); outputStream.flush(); outputStream.flush(); outputStream.flush(); protocol.verifyAll(); }
/** * Test the output stream flush() method. * * @throws Exception should not happen */ @Test public void shouldSendThirtyDataPackets() throws Exception { byte[] controlData = new byte[blockSize * 3]; InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream, initiatorJID); // set acknowledgments for the data packets IQ resultIQ = IBBPacketUtils.createResultIQ(initiatorJID, targetJID); for (int i = 0; i < controlData.length; i++) { protocol.addResponse(resultIQ, incrementingSequence); } OutputStream outputStream = session.getOutputStream(); for (byte b : controlData) { outputStream.write(b); outputStream.flush(); } protocol.verifyAll(); }
/** * Test the output stream write(byte[]) method. * * @throws Exception should not happen */ @Test public void shouldSendThreeDataPackets1() throws Exception { InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream, initiatorJID); // verify the data packets protocol.addResponse(null, incrementingSequence); protocol.addResponse(null, incrementingSequence); protocol.addResponse(null, incrementingSequence); byte[] controlData = new byte[blockSize * 3]; OutputStream outputStream = session.getOutputStream(); outputStream.write(controlData); outputStream.flush(); protocol.verifyAll(); }
/** * Test the output stream write(byte) method. * * @throws Exception should not happen */ @Test public void shouldSendThreeDataPackets2() throws Exception { InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream, initiatorJID); // verify the data packets protocol.addResponse(null, incrementingSequence); protocol.addResponse(null, incrementingSequence); protocol.addResponse(null, incrementingSequence); byte[] controlData = new byte[blockSize * 3]; OutputStream outputStream = session.getOutputStream(); for (byte b : controlData) { outputStream.write(b); } outputStream.flush(); protocol.verifyAll(); }
/** * Test the output stream write(byte[], int, int) method. * * @throws Exception should not happen */ @Test public void shouldSendThreeDataPackets3() throws Exception { InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream, initiatorJID); // verify the data packets protocol.addResponse(null, incrementingSequence); protocol.addResponse(null, incrementingSequence); protocol.addResponse(null, incrementingSequence); byte[] controlData = new byte[(blockSize * 3) - 2]; OutputStream outputStream = session.getOutputStream(); int off = 0; for (int i = 1; i <= 7; i++) { outputStream.write(controlData, off, i); off += i; } outputStream.flush(); protocol.verifyAll(); }
/** * Test the output stream write(byte[]) method. * * @throws Exception should not happen */ @Test public void shouldSendThreeDataPackets1() throws Exception { InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream, initiatorJID); // set acknowledgments for the data packets IQ resultIQ = IBBPacketUtils.createResultIQ(initiatorJID, targetJID); protocol.addResponse(resultIQ, incrementingSequence); protocol.addResponse(resultIQ, incrementingSequence); protocol.addResponse(resultIQ, incrementingSequence); byte[] controlData = new byte[blockSize * 3]; OutputStream outputStream = session.getOutputStream(); outputStream.write(controlData); outputStream.flush(); protocol.verifyAll(); }
/** * Test the output stream write(byte) method. * * @throws Exception should not happen */ @Test public void shouldSendThreeDataPackets2() throws Exception { InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream, initiatorJID); // set acknowledgments for the data packets IQ resultIQ = IBBPacketUtils.createResultIQ(initiatorJID, targetJID); protocol.addResponse(resultIQ, incrementingSequence); protocol.addResponse(resultIQ, incrementingSequence); protocol.addResponse(resultIQ, incrementingSequence); byte[] controlData = new byte[blockSize * 3]; OutputStream outputStream = session.getOutputStream(); for (byte b : controlData) { outputStream.write(b); } outputStream.flush(); protocol.verifyAll(); }
/** * Test accept() method. * * @throws Exception should not happen */ @Test public void shouldReturnSessionIfRequestIsAccepted() throws Exception { InBandBytestreamRequest ibbRequest = new InBandBytestreamRequest( byteStreamManager, initBytestream); // accept request InBandBytestreamSession session = ibbRequest.accept(); // capture reply to the In-Band Bytestream open request ArgumentCaptor<IQ> argument = ArgumentCaptor.forClass(IQ.class); verify(connection).sendStanza(argument.capture()); // assert that reply is the correct acknowledgment packet assertEquals(initiatorJID, argument.getValue().getTo()); assertEquals(IQ.Type.result, argument.getValue().getType()); assertNotNull(session); assertNotNull(session.getInputStream()); assertNotNull(session.getOutputStream()); }
/** * Test the output stream write(byte[], int, int) method. * * @throws Exception should not happen */ @Test public void shouldSendThreeDataPackets3() throws Exception { InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream, initiatorJID); // set acknowledgments for the data packets IQ resultIQ = IBBPacketUtils.createResultIQ(initiatorJID, targetJID); protocol.addResponse(resultIQ, incrementingSequence); protocol.addResponse(resultIQ, incrementingSequence); protocol.addResponse(resultIQ, incrementingSequence); byte[] controlData = new byte[(blockSize * 3) - 2]; OutputStream outputStream = session.getOutputStream(); int off = 0; for (int i = 1; i <= 7; i++) { outputStream.write(controlData, off, i); off += i; } outputStream.flush(); protocol.verifyAll(); }
session.getOutputStream().flush();
OutputStream outputStream = session.getOutputStream(); outputStream.close();
@Test public void shouldReturnSession() throws Exception { InBandBytestreamManager byteStreamManager = InBandBytestreamManager.getByteStreamManager(connection); IQ success = IBBPacketUtils.createResultIQ(targetJID, initiatorJID); protocol.addResponse(success, Verification.correspondingSenderReceiver, Verification.requestTypeSET); // start In-Band Bytestream InBandBytestreamSession session = byteStreamManager.establishSession(targetJID); assertNotNull(session); assertNotNull(session.getInputStream()); assertNotNull(session.getOutputStream()); protocol.verifyAll(); }
public OutputStream createOutgoingStream(String streamID, String initiator, String target) throws XMPPException { InBandBytestreamSession session = this.manager.establishSession(target, streamID); session.setCloseBothStreamsEnabled(true); return session.getOutputStream(); }
public OutputStream createOutgoingStream(String streamID, String initiator, String target) throws XMPPException { InBandBytestreamSession session = this.manager.establishSession(target, streamID); session.setCloseBothStreamsEnabled(true); return session.getOutputStream(); }
public OutputStream createOutgoingStream(String streamID, String initiator, String target) throws XMPPException { InBandBytestreamSession session = this.manager.establishSession(target, streamID); session.setCloseBothStreamsEnabled(true); return session.getOutputStream(); }